1
$\begingroup$

The new GraphicsColumn function claims to have the ability to align the axes Align Frame Edges. It works fine for very very simple plots, but if one adds a simple thing such as plot legends to it, it will not work anymore. For example, a simple plot as below works:

 plot1 = ListLinePlot[{Range[10], Range[11, 20]},
   Axes -> False,
   Frame -> True];
plot2 = ListLinePlot[{Range[41, 50], Range[61, 115]},
   PlotStyle -> {Red, Black},
   Axes -> False,
   Frame -> True];
plots = {plot1, plot2};
GraphicsColumn[plots]

But once we added legends, things start to break down:

plot1 = ListLinePlot[{Range[10], Range[11, 20]},
   PlotLegends -> {"line 1", "line 2"},
   Axes -> False,
   Frame -> True];
plot2 = ListLinePlot[{Range[41, 50], Range[61, 115]},
   PlotStyle -> {Red, Black},
   PlotLegends -> {"line 3", "line 4"},
   Axes -> False,
   Frame -> True];
plots = {plot1, plot2};
GraphicsColumn[plots]

Mathematica really need to do something to catch up with Python in terms of visualization capabilities.

$\endgroup$
  • 1
    $\begingroup$ Do you have a question or is this just a rant? $\endgroup$ – m_goldberg Apr 20 at 1:14
  • $\begingroup$ Plots can easily be aligned by giving both plots the same image padding such as ImagePadding -> {{30, 5}, {30, 5}}. I realize how frustrating it can be when things don't work the way you expect when you're new to a language, but this community is pretty good at helping if you give them a chance, either by asking a well-posed question or looking through answers to old questions. Vertically aligning two separate plots $\endgroup$ – MassDefect Apr 20 at 1:54
  • $\begingroup$ Try Spacings -> -100. $\endgroup$ – David G. Stork Apr 20 at 2:11
  • $\begingroup$ ImagePadding works well. Thanks @MassDefect. $\endgroup$ – baker Apr 20 at 14:29
1
$\begingroup$

I always use Multicolumn for alignment. Using the same ImagePadding for all figures is crucial.

imgPad = {{20, 2}, {20, 6}};
plot1 = ListLinePlot[{Range[10], Range[11, 20]}, 
   ImagePadding -> imgPad, PlotLegends -> {"line 1", "line 2"}, 
   Axes -> False, Frame -> True];
plot2 = ListLinePlot[{Range[41, 50], Range[61, 115]}, 
   ImagePadding -> imgPad, PlotStyle -> {Red, Black}, 
   PlotLegends -> {"line 3", "line 4"}, Axes -> False, Frame -> True];
Multicolumn[{plot1, plot2}, 1]

enter image description here

$\endgroup$
0
$\begingroup$

Try with the following within the GraphicsColumn: Spacings->-80

enter image description here

$\endgroup$
  • $\begingroup$ This doesn't appear to align the edges of the frames. It's close on the right side, but a bit off on the left side. $\endgroup$ – MassDefect Apr 20 at 3:19
  • $\begingroup$ I think the choice by @MassDefect using the "image padding" is the best. I will try to structure the post more like a question not a rant in the future. $\endgroup$ – baker Apr 20 at 14:26
0
$\begingroup$

GraphicsColumn together with GraphicsRow and GraphicsGrid are a bit problematic tools. There is problem with determination of AspectRatio for resulting graphics. Moreover, the plot with legend is a combined object and therefore the aspect ration is another than for pure plots.

You should define the AspectRatio directly in both plots to obtain normal view.

plot1 = ListLinePlot[{Range[10], Range[11, 20]}, 
   PlotLegends -> {"line 1", "line 2"}, Axes -> False, Frame -> True, 
   AspectRatio -> 0.6, ImageSize -> 400];
plot2 = ListLinePlot[{Range[41, 50], Range[61, 115]}, 
   PlotStyle -> {Red, Black}, PlotLegends -> {"line 3", "line 4"}, 
   Axes -> False, Frame -> True, AspectRatio -> 0.6, ImageSize -> 400];
plots = {plot1, plot2};
GraphicsColumn[plots, ImageSize -> 500, AspectRatio -> 0.6]

enter image description here

$\endgroup$

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.