Mathematica里的PlotLegend的例子也比较一般,网上讨论区里说Mathematica的PlotLegend有点问题。
不过那个Epilog和Prolog的功能比较强,可以随便来加任何图标。
Code:
plmarkers = {{"\[FilledCircle]", Medium}, {"\[FilledSquare]",
Medium}, {"\[FilledDiamond]", Medium}};
p2 = ListPlot[
Table[{k,
PDF[BinomialDistribution[50, p], k]}, {p, {0.3, 0.5, 0.8}}, {k, 0,
50}], Filling -> {1 -> {0,
Directive[Red, Thick, Dashed, Opacity[0.4]]},
2 -> {Axis, Directive[Purple, Dotted, Thick]}, 3 -> {Axis, Blue}},
FrameStyle -> Directive[Arrowheads[0.05], Thick, 12],
FillingStyle -> Directive[Thick, Dashed],
PlotStyle -> {Red, Directive[PointSize[Medium], Purple], Blue},
PlotMarkers -> plmarkers,
FrameLabel -> {Text[Style["k", Bold, 24]],
Text[Style["PDF", Bold, 20]]}, AxesOrigin -> {0, 0},
ImageMargins -> {{10, 10}, {10, 10}},
Epilog -> {PointSize[0.02], Point[{0, 0}],
Text[Style["p=0.3", Italic, Bold, 16], {15, 0.13}, {0, 0}, {1,
0}], Text[
Style["p=0.5", Italic, Bold, 16], {25, 0.13}, {0, 0}, {1, 0}],
Text[Style["p=0.8", Italic, Bold, 16], {45, 0.13}, {0, 0}, {1,
0}]}, Prolog ->
Inset[Framed@
Graphics[{Text[Style["\[FilledCircle]", Red], {0, 0}, {1, 0}],
Text[Style["p=0.3", Italic, Bold, 10], {8, 0}, {1, 0}],
Text[Style["\[FilledSquare]", Purple], {0, -1}, {1, 0}],
Text[Style["p=0.5", Italic, Bold, 10], {8, -1}, {1, 0}],
Text[Style["\[FilledDiamond]", Blue], {0, -2}, {1, 0}],
Text[Style["p=0.5", Italic, Bold, 10], {8, -2}, {1, 0}]},
ImageSize -> 40, AspectRatio -> 1], {6, 0.1}, {0, 0}, 10],
PlotLabel ->
Style["BinomialDistribution Plot",
Directive[Pink, FontFamily -> "Helvetica", 24, Bold]],
Frame -> True, ImageSize -> 400]
另外一个例子:
funct[x_] := Exp[-x/10] - Cos[30 x] Exp[-3 x]
short = Plot[funct[x], {x, 0, 1}, Frame -> True];
Plot[funct[x], {x, 0, 50}, Frame -> True,
Prolog -> {Inset[short, {35, 1.1}, Center, ImageScaled[{0.5, 0.5}]],
Inset[Text[
Style["Figure 1. Inset Function", Bold, 16]], {25, -0.5},
Center]}, PlotRangeClipping -> False, PlotRange -> Full,
ImageMargins -> {{10, 10}, {10, 10}},
ImagePadding -> {{20, 10}, {65, 10}}]
file:///C:/DOCUME%7E1/bing/LOCALS%7E1/Temp/moz-screenshot.jpg |