« View all new features in
Mathematica
9
◄
previous
|
next
►
New in
Mathematica
9
›
Legends
Systemwide Support of Legends
In[1]:=
X
style = Sequence @@ {Frame -> False, FrameTicks -> False, Axes -> True, AxesStyle -> Lighter@Gray, TicksStyle -> Gray, LabelStyle -> {GrayLevel[0.3], 8, FontFamily -> "Helvetica"}, ImageSize -> 180, AspectRatio -> 1/GoldenRatio}; Grid[Partition[ RandomSample[{DateListPlot[{FinancialData["GOOG", "Sep. 1, 2012"], FinancialData["AAPL", "Sep. 1, 2012"]}, PlotMarkers -> Automatic, PlotStyle -> (ColorData[75] /@ Range[2]), PlotLegends -> PointLegend[{"stockA", "stockB"}, LabelStyle -> {GrayLevel[0.3], 10, FontFamily -> "Helvetica"}], PlotLabel -> "DateListPlot", Evaluate@style], LogLogPlot[{(x + 1)^2, (x + 1)^3, (x + 1)^4, (x + 1)^5}, {x, 1, 10}, PlotLegends -> LineLegend["Expressions", LabelStyle -> {GrayLevel[0.3], 10, FontFamily -> "Helvetica"}], PlotStyle -> (Directive[ AbsoluteThickness[2], #] & /@ (ColorData[81] /@ Range[4])), PlotLabel -> "LogLogPlot", Evaluate@style], ArrayPlot[CellularAutomaton[{1635, {3, 1}}, {{1}, 0}, 10], ColorRules -> (Thread[{0, 1, 2} -> (ColorData[64] /@ Range[3])]), PlotLegends -> Placed[SwatchLegend[Automatic, LabelStyle -> {GrayLevel[0.3], 10, FontFamily -> "Helvetica"}], After], Frame -> True, style, PlotLabel -> "ArrayPlot"], DiscretePlot[ Evaluate[ Table[PDF[PoissonDistribution[k], x], {k, {8, 12, 16}}]], {x, 25}, ExtentSize -> Full, PlotStyle -> (Directive[ AbsoluteThickness[2], #] & /@ (ColorData[68] /@ Range[3])), PlotLegends -> LineLegend[{8, 12, 16}, LabelStyle -> {GrayLevel[0.3], 10, FontFamily -> "Helvetica"}], Evaluate@style, PlotLabel -> "DiscretePlot"], PolarPlot[{Sin[4 \[Theta]], Sin[2 \[Theta]]}, {\[Theta], 0, 2 Pi}, Evaluate@style, PlotLegends -> LineLegend["Expressions", LabelStyle -> {GrayLevel[0.3], 10, FontFamily -> "Helvetica"}], PlotLabel -> "PolarPlot", PlotStyle -> (Directive[ AbsoluteThickness[2], #] & /@ (ColorData[90] /@ Range[2]))], ParametricPlot[{Im[{Sqrt[Sin[2 u]] Cos[u], Sqrt[Sin[2 u]] Sin[u]}], Re@{Sqrt[Sin[2 u]] Cos[u], Sqrt[Sin[2 u]] Sin[u]}}, {u, 0, 2 Pi}, Evaluate@style, PlotLegends -> LineLegend[{"imaginary", "real"}, LabelStyle -> {GrayLevel[0.3], 10, FontFamily -> "Helvetica"}], PlotLabel -> "ParametricPlot", PlotStyle -> (Directive[ AbsoluteThickness[2], #] & /@ (ColorData[82] /@ Range[2]))], ListContourPlot[RandomReal[1, {10, 10}], InterpolationOrder -> 3, PlotLegends -> Placed[BarLegend[Automatic, LabelStyle -> {GrayLevel[0.3], 10, FontFamily -> "Helvetica"}], After], Frame -> True, Axes -> False, Evaluate@style, PlotLabel -> "ListContourPlot"], ListDensityPlot[ Table[Sin[j^2 + i], {i, 0, Pi, Pi/5}, {j, 0, Pi, Pi/5}], Mesh -> None, InterpolationOrder -> 2, ColorFunction -> "IslandColors", PlotLegends -> Placed[BarLegend[Automatic, LabelStyle -> {GrayLevel[0.3], 10, FontFamily -> "Helvetica"}], After], Frame -> True, Axes -> False, Evaluate@style, PlotLabel -> "ListDensityPlot"], SmoothHistogram[ Table[RandomVariate[ExponentialDistribution[x], 100], {x, 1, 4, 1}], PlotLegends -> LineLegend[{1, 2, 3, 4}, LabelStyle -> {GrayLevel[0.3], 10, FontFamily -> "Helvetica"}], Evaluate@style, PlotStyle -> (Directive[ AbsoluteThickness[2], #] & /@ (ColorData[81] /@ Range[4])), PlotRange -> {{-1, 3}, All}, PlotLabel -> "SmoothHistogram"], SmoothDensityHistogram[ RandomVariate[BinormalDistribution[.5], 10], ColorFunction -> (Hue[1/5, 2/3, #] &), PlotLegends -> Placed[BarLegend[Automatic, LabelStyle -> {GrayLevel[0.3], 10, FontFamily -> "Helvetica"}], After], Frame -> True, Axes -> False, Evaluate@style, PlotLabel -> "SmoothDensityHistogram"]}], 2], Alignment -> {Left, Center}, Frame -> All, FrameStyle -> Gray]
Out[1]=