2
$\begingroup$

I use Mathematica 7.0 and as far as I know, there is not method PlotLegends, only PlotLegend. I want to set my legend - without background, shadow and frame - above my plot, as in the example belowe: enter image description here

I found the commend, which helps to reduce shadow, but I don't know how to make other settings. The main problem is that all information which I found are for PlotLegends which is not used in Mathematica 7

My plot enter image description here

My code:

ListPlot[{top, bottom},
 PlotStyle -> Directive[AbsolutePointSize[100]],
 GridLines -> Automatic, 
 GridLinesStyle -> Directive[Gray, Dashed],
 Frame -> {True, True, False, False},
 FrameLabel -> {"Number of non-zero bits", "alpha"},
 Axes -> False,
 LegendSize -> 0.5,
 LegendShadow -> None,
 PlotLegend -> {Style["exact value", FontFamily -> "Helvetica", 130], 
   Style["estimated value", FontFamily -> "Helvetica", 130]},
 LegendPosition -> {0 - .60, 0.30},
 PlotRange -> {0, 20},
 ImageSize -> 7000,
 PlotRangeClipping -> False]
$\endgroup$
1
$\begingroup$

Fairly close to what you're after. For version 7 use ColorData[1, ...] for the right colour set.

Needs["PlotLegends`"];

ShowLegend[Plot[{x, x^2, x^3}, {x, 0, 3},
  Frame -> True, ImageSize -> 500],
 {{{Graphics[{ColorData[97, 1], Thick, Line[{{0, 0}, {8, 0}}]}],
    Style["long text 1", 12, FontFamily -> "Helvetica"]},
   {Graphics[{ColorData[97, 2], Thick, Line[{{0, 0}, {8, 0}}]}],
    Style["long text 2", 12, FontFamily -> "Helvetica"]},
   {Graphics[{ColorData[97, 3], Thick, Line[{{0, 0}, {8, 0}}]}],
    Style["long text 3", 12, FontFamily -> "Helvetica"]}},
  LegendPosition -> {-1, 0.65}, LegendSize -> {2.1, 0.22},
  LegendShadow -> False, LegendBorderSpace -> 0.1, LegendTextSpace -> 0.6,
  LegendOrientation -> Horizontal, LegendBorder -> None}]

enter image description here

$\endgroup$
  • $\begingroup$ is it possible to have same features of PlotLegends in Mathematica 11? $\endgroup$ – Gae P Jul 18 '18 at 10:09
  • $\begingroup$ @GaeP The example still works in Mathematica 11, but it is legacy code You can use Quiet@Needs["PlotLegends`"] to suppress the warning messages. I expect the same result can be obtained using the newer PlotLegend functionality. I will see if I can add an example. $\endgroup$ – Chris Degnen Jul 18 '18 at 10:19
  • $\begingroup$ Thanks! this code doesn't work in M11. $\endgroup$ – Gae P Jul 18 '18 at 10:26
  • $\begingroup$ @GaeP I just ran it in 11.0 and 11.2 on Windows. Did you include the Needs statement? $\endgroup$ – Chris Degnen Jul 18 '18 at 10:38
  • $\begingroup$ Yes, but it doesn't work. Have i download any package? $\endgroup$ – Gae P Jul 18 '18 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.