# How to creat a specific/private legend in Mathematica 10 or 9 ?

Posted 8 years ago
5726 Views
|
3 Replies
|
1 Total Likes
|
 A test program, perfect in Earlier Version, but not 9. The problem is, how to do it with Mathematica 10 or 9?Needs["PlotLegends"] g1 = Plot[Sin[x], {x, 0, 2 Pi}]; legend = Join[{Graphics[{Thick, Blue, Dashed, Line[{{0, 2}, {15, 2}}]}], #1} & @@@ {{Style[ "\[CapitalOmega]=15", FontSize -> 11, FontFamily -> "Times New Roman"]}}, {Graphics[{Thick, Red, Dotted, Line[{{0, 2}, {15, 2}}]}], #1} & @@@ {{Style[ "\[CapitalOmega]=20", FontSize -> 11, FontFamily -> "Times New Roman"]}}, {Graphics[{Thick, Black, DotDashed, Line[{{0, 2}, {6, 2}}]}], #1} & @@@ {{Style[ "\[CapitalOmega]=30", FontSize -> 11, FontFamily -> "Times New Roman"]}}, {Graphics[{Thick, Black, Dashed, Line[{{0, 2}, {6, 2}}]}], #1} & @@@ {{Style[ "\[CapitalOmega]=40", FontSize -> 11, FontFamily -> "Times New Roman"]}}]; ShowLegend[ Show[g1], {legend, LegendPosition -> {0.5, 0.25}, LegendSize -> {0.5, 0.4}, LegendShadow -> None, LegendBorder -> None}]
3 Replies
Sort By:
Posted 8 years ago
 Also note that in your code above Needs["PlotLegends"] should read Needs["PlotLegends"] -- then the legacy package will load and your code will still work in V10.
Posted 8 years ago
 Use the new built-in Plotlegends capability. (Not to be confused with the old PlotLegend package.) I am sure you could work this to an identical form, but here is something which is perhaps suitable: omegaValues = {15, 20, 30, 40, 50}; plt = Plot[ Table[Sin[omega x], {omega, omegaValues}] // Evaluate, {x, 0, 2 Pi/First[omegaValues]}, PlotStyle -> Table[{Thick, Dashing[.03 {k, 1 - k}]}, {k, .2, 1, .2}], PlotLegends -> LineLegend[omegaValues, LegendLabel -> "Omega"]] 
Anonymous User
Anonymous User
Posted 8 years ago
 Thanks for your patience. it's useful for me. In fact, Legended may substitute for Needs["PlotLegends"] in V9/10.The label "lbl" in Legended[expr,lbl]` can be any expression, including graphics.