I've noticed (in v11.0.1 and v10.3.1) a small problem with the graphic produced withPlot and the PlotLegends option: if you try to select manually the whole output graphic (mouse click) it won't include the legends ! It means you can't manually export the whole plot ("Save graphics as"), because you'll loose the legends ...

For example with this example taken from the docs:

Plot[{Sin[x], Sin[2 x], Sin[3 x]}, {x, 0, 2 Pi}, PlotLegends -> "Expressions"]

i get the following (orange) graphic frame if I click on the graphic curves (nothing happens if i click on the legends)

enter image description here

There is no way to include these legends.

If you look at this same example in the docs (notebook not web) and select the graphic, it will include the legends because all the graphics where rasterized and are not anymore "native" plots (as indicated previously to me by @Michael E2).

I tried then to reproduce the doc "rasterized" graphic which actually has the Image type. It is interesting to see that the command:

Plot[{Sin[x],Sin[2x],Sin[3x]}, {x,0,2Pi}, PlotLegends -> "Expressions"] // Image

produces an error (while other plots without PlotLegends won't):

enter image description here

The workaround here is to use Rasterize before Image (though Image should give directly the same result):

Plot[{Sin[x],Sin[2x],Sin[3x]}, {x,0,2Pi}, PlotLegends -> "Expressions"] // 
Rasterize // Image

enter image description here

Once again, it is probably not a big problem as it concerns only the manual graphic export, but it looks clearly as a bug and there could be some other related (hidden) problems behind that ...

  • $\begingroup$ Is there a question here? If not I'd recommend you just send the information to WRI. It's less likely to be addressed if just posted here. $\endgroup$ – ktm Oct 4 '16 at 14:20
  • $\begingroup$ Another workaround: Evaluate Plot[{Sin[x], Sin[2 x], Sin[3 x]}, {x, 0, 2 Pi}, PlotLegends -> "Expressions"], copy the output cell's contents (not the cell itself, but highlight the graph + the legend), paste it into an empty text cell (alt+7), and then save this cell by right clicking on the cell bracket and select Save Selection As. A bit cumbersome, but it likely scales better than the rasterized image, and prevents saving the cell label (the original Out[#]) $\endgroup$ – ktm Oct 4 '16 at 14:25
  • $\begingroup$ @user6014 Thanks, i knew the cell bracket workaround but this was not my point. See my comment to JasonB answer. $\endgroup$ – SquareOne Oct 4 '16 at 20:19

I think you can't select the plot plus legend and "Save Graphic as" because it is a Legended object rather than a Graphics object.

If you want to save it using a menu command rather than Export, you can select the cell bracket rather than the graphic itself, and select "Save Selection As" from the File menu,

enter image description here

This brings up the same dialog box as "Save Graphic As" but includes the entire cell contents in the output file.

  • 1
    $\begingroup$ Good point: i completely missed the fact that the use of PlotLegends turned the plot Graphics object into a Legended object ! It explains why direct Image conversion does not work. BUT this is rather a very awkward feature ! It means that, potentially, any option can modify the default output type of a function !? Right know i don't recall any similar cases ... Do you ? Anyway, the problem concerns all the Legended objects ... I'll probably edit my post and title. $\endgroup$ – SquareOne Oct 4 '16 at 20:14
  • $\begingroup$ Concerning your workaround, yes i tried that before posting but this was not my point. $\endgroup$ – SquareOne Oct 4 '16 at 20:15
  • $\begingroup$ Wow! I always used external program to make a screenshot because legends were not included. Thanks! $\endgroup$ – BlacKow Oct 4 '16 at 21:49

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.