How to | Align Plots with Each Other

The Mathematica graphics language has many controls for preparing and laying out plots. Aligning plots is important when preparing graphics for presentation or publication.

Here are two plots of FinancialData plotted as a function of time:

In[0]:=
Click for copyable input

If you want to compare the two plots, you can make a grid:

In[2]:=
Click for copyable input
Out[2]=

But the axes do not exactly line up, which makes it harder to make a useful comparison.

(Mathematica automatically draws the plot area as large as possible and gives only as much space to the axis labels as is necessary. Normally this is what you want, but not in this case.)

The solution is to set the padding for the plot manually with the ImagePadding option:

In[3]:=
Click for copyable input

Now the axes on the plots line up:

In[6]:=
Click for copyable input
Out[6]=

You can also use ImagePadding to align plots in the horizontal as well as the vertical direction.

New to Mathematica? Find your learning path »
Have a question? Ask support »