# Adjusting figures of different size

I generated some figures using Matplotlib/Python.

I want to display them by lines and by columns/line.

This is my current code for the first case:

\begin{figure}[!htpb]
\centering
\subfloat[]{\includegraphics[width=5.3cm] {fig1}} \\
\vspace{-10pt}
\subfloat[]{\includegraphics[width=5.3cm] {fig2}} \\
\vspace{-10pt}
\subfloat[]{\includegraphics[width=5.3cm] {fig3}} \\
\end{figure}


And this is the result:

It's possible to note that the last image is 'larger' than the others, because its scale has two instead of three numbers.

I'm thinking about an approach to handle this. I thought about putting all figures left aligned inside a minipage, trying different sizes, and this minipage inside a figure environment, but it didn't seem to handle the problem:

\begin{figure}[!htpb]
\centering
\begin{minipage}{\columnwidth}
\subfloat[]{\includegraphics[width=5.3cm] {fig1}}   \\
\vspace{-10pt}
\subfloat[]{\includegraphics[width=5.3cm] {fig2}}    \\
\vspace{-10pt}
\subfloat[]{\includegraphics[width=5.3cm] {fig3}} \\
\end{minipage}
\end{figure}

• I'm a little confused. If the pictures actually have different aspect ratios then there's no way to make them the "same size". If the widths are the same the heights won't be, and vice versa. – Ethan Bolker Mar 30 '17 at 18:57
• if they have the same (visual) size originally, use scale= not width= to scale by same amount – David Carlisle Mar 30 '17 at 18:58
• @EthanBolker I suspect the issue is that the main blue maps are the same size but the actual images sizes are different to accommodate the scales so if you let tex calculate a scale factor based on the natural image width the effect is that teh one with smaller numbers gets scaled a different amount – David Carlisle Mar 30 '17 at 19:00
• @DavidCarlisle, they don't have the same size because of the color bars, but the main figure of each image has the same size, that why I though of a left alignment. I think it make sense. – pceccon Mar 30 '17 at 20:07
• @pceccon yes that's what I thought, so just replace your width= arguments to \includegraphics by scale=0.5 9or whatever scale you need) if you scale them all by the same amount then the visual effect will be that the main rectangles are same size. – David Carlisle Mar 30 '17 at 20:17

In order to keep the "main" rectangle of each image the same size just scale each image by the same amount so

    \subfloat[]{\includegraphics[scale=0.25] {fig1}}   \\


not

    \subfloat[]{\includegraphics[width=5.3cm] {fig1}}   \\


Obviously the exact scale factor (0.25 here) will depend on your original image size, which I do not know, but if you specify it, rather then let latex calculate the scale, they will all scale by the same amount.

• Thank you @DavidCarlisle. It worked. But it shouldn't affect all image? Don't get why it works. – pceccon Mar 31 '17 at 16:06
• @pceccon I'm not sure what part you don't get, if all the original images have the same size main rectangle, if you scale them all by the same amount, they will still have the same size main rectangle. – David Carlisle Mar 31 '17 at 16:30

If the main part of the figures have the same dimensions, you can use height instead; as far as I can see, the first image, together with the color bar at the right, is approximately square, so you can do with the following strategy.

\newlength{\imagewidth}


Then the code can be

\begin{figure}[!htpb]
\centering

\settowidth{\imagewidth}{\includegraphics[height=5.3cm]{fig1}}

\subfloat[]{\includegraphics[height=5.3cm]{fig1}}\\[-10pt]
\subfloat[]{\includegraphics[height=5.3cm]{fig2}}\\[-10pt]
\subfloat[]{\makebox[\imagewidth][l]{\includegraphics[height=5.3cm]{fig3}}}

\end{figure}


The trick with \makebox is in order to get aligned subcaptions.

My approach to this problem is to merge all the figures together into one in an external graphics program (e.g. Inkscape - it's free and it works for this sort of thing), and then insert it.

The advantage of that approach is you can get things aligned exactly as you'd like. The disadvantage is that it takes more effort from you to apply any changes to the figures in the future.