Best explained by example. The code,
p1 = Plot[Sin[x], {x, 0, 10}, PlotLegends -> {"sin(x)"}];
p2 = Plot[Cos[x], {x, 0, 10}, PlotLegends -> {"cos(x)"}, PlotStyle -> Red];
p3 = Show[p1, p2]
Gives me this nice picture:
Now I want to isolate the plots and legends for export, so I can do,
p1[[1]]
p1[[2, 1]]
Which gives me:
But doing this on the combination p3
,
p3[[1]]
p3[[2, 1]]
produces:
where only the legend from the first plot was extracted. Given two plots created separately with individual legends, is there a way to isolate the plot and legends?
It seems like I can isolate the plots with p3[[1]][[1]]
, but haven't managed to combine the legends. I know I can create the legend manually separately, but I'm less keen on doing that.
Is there a way I can inspect the object p3
more closely to answer this question for myself? Currently it seems like trial and error by adding [[1]]
indexing everywhere.
GraphicsRow[{p3[[1, 2, 1]], p3[[2, 1]]}]
$\endgroup$ – Feyre Sep 14 '16 at 12:37