# Having trouble saving a plot with legends

I am trying to plot a graph.

Subscript[R, 0] = 1.2;
Subscript[A, Pb] = 208 ;
Subscript[A, Ca] = 40;
Subscript[A, O] = 16;
Subscript[ρ, 0] = 0.138;
R[A_] := Subscript[R, 0]*(A^(1/3))
ρ[r_, R_, a_] := Subscript[ρ, 0]/(1 + Exp[(r - R)/a])


I cannot save the following plot with its legend.

a = 0.5;
Plot[{
ρ[r, R[Subscript[A, Pb]], a],
ρ[r, R[Subscript[A, Ca]], a],
ρ[r, R[Subscript[A, O]], a]},
{r, 0, 10},
Frame -> True,
FrameLabel -> {"r (fm)", "ρ(r) nucleons/fm\.b3"},
PlotLegends -> Placed[{"Pb", "Ca", "O"}, Right]]


I cannot select both the plot and legends to save them. How can I deal with this?

• To get a contextual menu allowing you to save the entire contents of a cell, right-click the cell bracket on the right of the output. Then choose Save Selection As... In your case, this will save the graphic and legend together.
– Jens
Commented May 29, 2014 at 5:00
• It works, thank you! Commented May 29, 2014 at 5:12
• @m_goldberg How did you typed the greek letter rho in? Commented May 29, 2014 at 6:22
• I used halirutan's plug-in Commented May 29, 2014 at 6:49

Name your plot (let us say p) and the export it.

a = 0.5;
p=Plot[{\[Rho][r, R[Subscript[A, Pb]], a], \[Rho][r,
R[Subscript[A, Ca]], a], \[Rho][r, R[Subscript[A, O]], a]}, {r, 0,
10}, Frame -> True,
FrameLabel -> {"r (fm)", "\[Rho](r) nucleons/fm\.b3"},
PlotLegends -> Placed[{"Pb", "Ca", "O"}, Right]]


and then export it using export command

Export["plot.jpg", p]


you will find the picture in the default folder which is normally Documents.