« View all new features in
Mathematica
9
◄
previous
|
next
►
New in
Mathematica
9
›
Legends
Legend-Specific Curves
In[1]:=
X
d1 = Table[PDF[NormalDistribution[0, 1], x], {x, -3, 3, 0.1}]; d2 = Table[PDF[NormalDistribution[0, 0.5], x], {x, -3, 3, 0.1}]; dm = Mean /@ Transpose[{d1, d2}]; styles = Sequence @@ {PlotStyle -> {Directive[AbsoluteThickness[5], Opacity[0.5], ColorData[45][1]], Directive[AbsoluteThickness[7], ColorData[45][4]], Directive[AbsoluteThickness[5], Opacity[0.5], ColorData[45][10]]}, ImageSize -> 400, PlotRange -> All, AxesStyle -> Gray, Ticks -> None};
Plot two datasets and their mean, with a legend identifying the mean curve.
In[2]:=
X
ListLinePlot[{d1, Legended[dm, "mean"], d2}, DataRange -> {-3, 3}, Evaluate@styles, Filling -> {1 -> {3}}, FillingStyle -> Opacity[0.1], PlotLegends -> LineLegend[None, LegendMarkerSize -> {40, 10}, LabelStyle -> {20, Bold, GrayLevel[0.3]}]]
Out[2]=