2012-03-29 94 views
3

我在Mathematica中繪圖函數遇到問題。 我試圖在一個半對數圖上繪製幾個數據列表,然後添加一個圖例。情節是罰款:將圖例添加到Mathematica的半對數圖中

enter image description here

Show[ListLogPlot[bead31, PlotStyle -> Black, 
    PlotMarkers -> {"\[FilledSmallSquare]"}], 
ListLogPlot[bead27, PlotStyle -> Blue, 
    PlotMarkers -> {"\[FilledSmallSquare]"}], 
ListLogPlot[A5, PlotStyle -> Red, 
    PlotMarkers -> {"\[FilledSmallSquare]"}], 
ListLogPlot[A10, PlotStyle -> Green, 
    PlotMarkers -> {"\[FilledSmallSquare]"}], 
ListLogPlot[A20, PlotStyle -> Gray, 
    PlotMarkers -> {"\[FilledSmallSquare]"}], Frame -> True, 
FrameLabel -> {Subscript[t, norm], \[Kappa]}, RotateLabel -> False, 
PlotRange -> Automatic] 

但是,任何試圖加入一個傳說或者失敗,或者被放置在同樣的規模 - 而且由於它是一個半對數圖,所有我看到的是一個線一個傳奇。

我想單獨創建我的傳說作爲一個圖形對象:

enter image description here

,但我無法弄清楚如何將它放置在圖像中(我與插圖[]和結語[玩],但我認爲我用他們錯了)。

Show[Graphics[ 
    Legend[{{Graphics[{Black, Rectangle[{-1, -1}, {1, 1}]}], 
    "31 beads"}, {Graphics[{Blue, Rectangle[{-1, -1}, {1, 1}]}], 
    "27 beads"}, 
    {Graphics[{Red, Rectangle[{-1, -1}, {1, 1}]}], "A5"}, 
    {Graphics[{Green, Rectangle[{-1, -1}, {1, 1}]}], "A10"}, 
    {Graphics[{Gray, Rectangle[{-1, -1}, {1, 1}]}], "A20"}}]]] 

如果有人知道如何正確添加圖例到第一個圖表,任何幫助將不勝感激。

+0

相關http://stackoverflow.com/a/7788587/353410 – 2012-03-30 03:59:28

回答

3

也許:

Needs["PlotLegends`"]; 
ListLogPlot[{ 
    Table[PartitionsQ[n], {n, 50}], 
    Table[{n, n!}, {n, 1, 20, .1}]}, 
    PlotLegend -> {"Parts", "Fact"}, LegendPosition -> {0.8, -0.8}] 

enter image description here

+0

啊,那工作!我一直試圖在Show命令中添加PlotLegend命令。謝謝您的幫助! – scallionpancake 2012-03-31 20:35:46