« View all new features in
Mathematica
9
◄
previous
|
next
►
New in
Mathematica
9
›
Legends
Use Anything as a Legend
In[1]:=
X
text = Style["legend", FontFamily -> "Arial", 25, GrayLevel[0.3]]; graphics = Graphics[Table[{Hue[i/2 \[Pi]], Opacity[0.5], Disk[{Sin[i], Cos[i]}, 0.5]}, {i, 0, 2 \[Pi], \[Pi]/6}], ImageSize -> 50]; table = Grid[Array[Subscript[a, ##] &, {3, 2}], Frame -> All, FrameStyle -> Gray]; graphics3d = Graphics3D[Sphere[], ImageSize -> 65]; image = ImageCrop[ ImageResize[ExampleData[{"TestImage", "Splash"}], 70], 60]; control = VerticalSlider[ImageSize -> Small]; plot = Histogram[ Table[RandomReal[{0, 10}] Sin[x], {x, 0, 2 \[Pi], 0.05}], BarOrigin -> Left, AspectRatio -> 2, ImageSize -> 60, Axes -> {False, True}, Ticks -> None]; formula = HoldForm[Integrate[x^x, {x, 0, Infinity}]];
Create legends using anything, including tables, text, images, and graphics.
In[2]:=
X
Grid[{{Plot[Sin[x], {x, 0, 2 \[Pi]}, PlotLegends -> text], Plot[Sin[x], {x, 0, 2 \[Pi]}, PlotLegends -> graphics]}, {Plot[ Sin[x], {x, 0, 2 \[Pi]}, PlotLegends -> image], Plot[Sin[x], {x, 0, 2 \[Pi]}, PlotLegends -> formula]}, {Plot[ Sin[x], {x, 0, 2 \[Pi]}, PlotLegends -> table], Plot[Sin[x], {x, 0, 2 \[Pi]}, PlotLegends -> plot]}, {Plot[ Sin[x], {x, 0, 2 \[Pi]}, PlotLegends -> graphics3d], Plot[Sin[x], {x, 0, 2 \[Pi]}, PlotLegends -> control]}}, Frame -> All, FrameStyle -> Gray]
Out[2]=