Message Boards Message Boards

How to export a plot (or graph) together with its legend?

Posted 9 years ago
POSTED BY: Rene Samson
5 Replies
Posted 9 years ago
POSTED BY: Hadi Tokme
Posted 9 years ago
POSTED BY: David Keith
Posted 9 years ago
POSTED BY: Rene Samson
Posted 9 years ago

I find that when using legends created by PlotLegends, selecting the graphic and then using "Save graphic as" does not include the legend, apparently because the legend graphic is not selectable. However, assigning the graphic to a variable and using export does include the legend. For example:

p1 = Plot[{Sin[x], Cos[x]}, {x, 0, 2 Pi}, 
   PlotLegends -> "Expressions"];

Export["exportP1.png", p1]

will save p1 as a png and it will include the legend.

I'm on 10.0.2 and Win 7 x64.

POSTED BY: David Keith
POSTED BY: Sean Clarke
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract