2011-10-15 26 views
3
daList={{0.059, 0.298, 0.726, 0.735, 1.461, 2.311, 3.315}, 
     {0.05, 0.404,0.664, 0.782, 1.376, 2.328, 3.432}, 
     {0.087, 0.628, 0.986, 1.187,1.914, 3.481, 4.993}, 
     {0.073, 0.594, 0.975, 1.147, 2.019, 3.417,5.037}, 
     {0.143, 0.821, 1.442, 1.595, 2.983, 4.98, 7.604}, 
     {0.107,0.871, 1.431, 1.684, 2.964, 5.015, 7.394}} 


ListPlot[daList, 
     Joined -> True, 
     PlotRange -> {{1, 7}, {0, 7}}, 
     PlotStyle -> {{Thick, Lighter[Red, .5]}, 
         {Dashed, Black}, 
         {Thick,Lighter[Red, .3]}, 
         {Dashed, Black}, 
         {Thick,Lighter[Red, .1]}, 
         {Dashed, Black}}, 
     Prolog ->{GrayLevel[0.5], EdgeForm[Thickness[.005]], 
        Rectangle[{1.01, 0.01}, {6.99, 6.99}]}] 

enter image description here爲listPlot

正如你可以看到多個指令,我需要不同的指令分配給每個行。

我希望虛線黑線是點(連接 - >錯誤)。

我無法掌握的方法來爲子列表分組指令。

謝謝您的關注。

+0

我讀這兩次,但我仍然有麻煩想象它。你可能畫一幅你想要的畫嗎? –

+0

好吧,讓我試試! – 500

+0

謝謝,抱歉;這可能很清楚,但我思考不好。 –

回答

5

如果你想被加入所有其他的情節,你可以只設置Joined->{True, False},例如

ListPlot[daList, Joined -> {True, False}, 
PlotRange -> {{1, 7}, {0, 7}}, 
PlotStyle -> {{Thick, Lighter[Red, .5]}, {Dashed, Black}, {Thick, 
    Lighter[Red, .3]}, {Dashed, Black}, {Thick, 
    Lighter[Red, .1]}, {Dashed, Black}}, 
Prolog -> {GrayLevel[0.5], EdgeForm[Thickness[.005]], 
    Rectangle[{1.01, 0.01}, {6.99, 6.99}]}] 

產生

joined/not joined

編輯

關於你的評論,我想你總是可以單獨繪製奇數和偶數點的集合,並與節目結合他們。因此,對於你的例子:

joinedStyle = {Thick, Lighter[Red, #]} & /@ {.5, .3, .1}; 
pointStyle = Black; 

plot1 = ListPlot[daList[[1 ;; ;; 2]], Joined -> True, PlotStyle -> joinedStyle, 
    PlotRange -> {{1,7},{0,7}}]; 
plot2 = ListPlot[daList[[2 ;; ;; 2]], Joined -> False, PlotStyle -> pointStyle]; 
Show[plot1, plot2, PlotRange -> {{1, 7}, {0, 7}}, 
    Prolog -> {GrayLevel[0.5], EdgeForm[Thickness[.005]], 
    Rectangle[{1.01, 0.01}, {6.99, 6.99}]}] 
+0

謝謝!問題是我有10 * 2曲線來繪製。我希望列表中的奇數位置只有2組指令(粗線與顏色變淺),偶數(黑色)中的一個指向奇數編號的存在指令。你有沒有看到這個意思? – 500

+0

@ 500:請參閱編輯。 – Heike

+0

謝謝你,Heike! – 500

4

您可以考慮分別構建您的地塊,並將其與Show分層。這裏有一個例子,希望不會太離譜。

{d1, d2} = Partition[daList, 2]\[Transpose]; 
lambda = {541, 550, 560, 570, 580, 590, 600}; 
colors = {Thick, Red~Lighter~#} & /@ {0.5, 0.3, 0.1}; 

g1 = ListPlot[d1, Joined -> True, PlotStyle -> colors]; 
g2 = ListPlot[d2, PlotStyle -> {{Black, AbsolutePointSize[5]}}]; 

Show[{g1, g2}, PlotRange -> {{1, 7}, {0, 7}}, 
AspectRatio -> 1/GoldenRatio, Frame -> True, FrameStyle -> 20, 
FrameTicks -> {{Automatic, 
    None}, {MapIndexed[{#2[[1]], #} &, lambda], Automatic}}, 
Prolog -> {GrayLevel[0.5], EdgeForm[Thickness[.005]], 
    Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}, ImageSize -> 600] 

我想我幾乎複製海克在這裏,但它是不是故意的。希望這兩個答案都可以補充一些。

有使用ScaledImageScaled在這個非常的應用程序的一個更完整的例子:https://stackoverflow.com/questions/6303500/mathematica-matlab-like-figure-plot

+0

太整潔了!謝謝,任何建議,使灰盒完美適合的情節:-)? – 500

+0

@ 500表示與現在不同的外觀,或者自動適應PlotRange,所以對於其他尺寸看起來是一樣的? –

+0

自動擬合繪圖範圍將是理想的! – 500

3

作爲替代ListPlot,你可以考慮Graphics

tdata = MapIndexed[{#2[[1]], #1} &, #] & /@ daList; 

Graphics[ 
{ GrayLevel[0.7], EdgeForm[AbsoluteThickness[2]], 
    Rectangle[{1.02, 0.05}, {7.2, 7.75}], 
    (*lines*) 
    AbsoluteThickness[2], 
    Transpose[{Lighter[Red, #] & /@ {0.5, 0.3, 0.1}, 
    [email protected][[#]] & /@ {1, 3, 5}}], 
    (*points*) 
    Black, PointSize[0.016], 
    [email protected][[#]] & /@ {2, 4, 6} 
    }, Axes -> True, PlotRange -> {{1, 7.2}, {0, 7.8}}, 
AspectRatio -> 1/GoldenRatio] 

給出

enter image description here

,或者給每個數據設置不同的符號,如下面的情節:

enter image description here

代碼:

Graphics[ 
{ GrayLevel[.7], EdgeForm[AbsoluteThickness[2]], 
    Rectangle[{1.02, 0.05}, {7.2, 7.75}], 

    (*lines*) 
    AbsoluteThickness[2], 
    Transpose[{Lighter[Red, #] & /@ {0.5, 0.3, 0.1}, 
    [email protected][[#]] & /@ {1, 3, 5}}], 

    (*points*) 

    Inset[Graphics[{EdgeForm[Black], White, Rectangle[]}, 
     ImageSize -> 8], #] & /@ tdata[[2]], 
    Inset[Graphics[{EdgeForm[Black], White, 
     Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}]}, 
     ImageSize -> 10], #] & /@ tdata[[4]], 
    Inset[Graphics[{ EdgeForm[Black], White, Disk[]}, 
     ImageSize -> 9], #] & /@ tdata[[6]] 

    }, Axes -> True, PlotRange -> {{1, 7.2}, {0, 7.8}}, 
AspectRatio -> 1/GoldenRatio] 
相關問題