0
$\begingroup$

I would like to make a single plot which contains two graphs on top of each other like the plot below (with frames, axes labels and the legend on the top right corner)

enter image description here

I read this question and tried to implement it, but it did not work because it removes the labels of the axes when I use ImagePadding . Could somebody give me an example of how to do this?

$\endgroup$
2
$\begingroup$

Do you mean something like this?

p1 = Plot[Sin[x], {x, 0, 2 Pi},
   Frame -> True,
   PlotLegends -> Placed[Framed[LineLegend[{Automatic}, {"Something"}]], ImageScaled[{.8, .9}]]];

p2 = Plot[Cos[x], {x, 0, 2 Pi},
   Frame -> True,
   PlotLegends -> Placed[Framed[LineLegend[{Automatic}, {"Something"}]], ImageScaled[{.8, .9}]]];

GraphicsColumn[{p1, p2}]

enter image description here

$\endgroup$
4
  • $\begingroup$ Almost there! How do I modify the spacing between the two plots? I ran the code but the spacing between them is too large. I want them a bit closer to each other. $\endgroup$ – eemg Oct 13 '20 at 1:15
  • $\begingroup$ @eemg Add the Spacings -> Scaled[0] option to GraphicsGrid. Use a negative value rather than 0 to further decrease, but that might cause overlaps. $\endgroup$ – Rohit Namjoshi Oct 13 '20 at 1:23
  • $\begingroup$ There is also: GraphicsGrid[{{p1}, {p2}}] $\endgroup$ – Daniel Huber Oct 13 '20 at 10:30
  • $\begingroup$ You can also use ResourceFunction\[“PlotGrid”\] which would do exactly what you want here! $\endgroup$ – CA Trevillian Oct 13 '20 at 20:21

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.