« View all new features in
Mathematica
9
◄
previous
|
next
►
New in
Mathematica
9
›
Legends
Combine Legends from Several Plots
In[1]:=
X
legendoptions = {LabelStyle -> {Bold, GrayLevel[0.3], 14}, LegendMarkerSize -> {15, 10}};
In[2]:=
X
SeedRandom[44]; data = RandomVariate[NormalDistribution[], 100];
Combine two plots and their respective legends.
In[3]:=
X
normalplot = Plot[PDF[NormalDistribution[], x], {x, -3, 3}, PlotStyle -> Directive[Thick, Gray], Filling -> Axis, FillingStyle -> LightGray, PlotLegends -> Placed[LineLegend[{"normal"}, legendoptions], Above]]
Out[3]=
In[4]:=
X
histogram = SmoothHistogram[data, PlotStyle -> Directive[Thick, Orange], PlotLegends -> Placed[LineLegend[{"data"}, legendoptions], Above]]
Out[4]=
In[5]:=
X
Grid[{{Show[normalplot, Ticks -> None, ImageSize -> 150], Show[normalplot, histogram, PlotRange -> All, ImageSize -> 350]}, {Show[histogram, Ticks -> None, ImageSize -> 150], SpanFromAbove}}, Frame -> All, Alignment -> {Left, Center}]
Out[5]=