How can I save both the plot and the legend together?
This is how to save the graph, legend and all:
Another way would be to use Rasterize
:
Rasterize[Plot[...]]
The legend and the graph is now one image.
You can define :
sol = Solve[Expr1 == Expr2, p][[1, 1]] ;
plot = Plot[{Expr1, Expr2, Expr3}, {p, 0, 1},
BaseStyle -> AbsoluteThickness[4],
PlotLegends -> Placed[LineLegend["Expressions", BaseStyle -> AbsoluteThickness[4]], {Left, Center}],
Epilog -> Inset[sol, {0.5, 0.5}]]
and export with
Export["/tmp/plot.png", plot]
Or you can use the full form position specification with Placed
to position legend "inside" the graph and use Legended
to put any additional legends.
Legended[Plot[{Expr1, Expr2, Expr3}, {p, 0, 1},
BaseStyle -> AbsoluteThickness[4],
PlotLegends ->
Placed[LineLegend["Expressions",
BaseStyle -> AbsoluteThickness[4]], {1.05, 0.5}]],
Placed[First@First@Solve[Expr1 == Expr2, p], {0.5, 1}]]