Combining 4 plots into one figure

Assuming you are using LaTeX to write your paper, you could use a LaTeX
solution. Here are some links:

http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions#Subfloats
ftp://ctan.tug.org/tex-archive/macros/latex/contrib/subfig/subfig.pdf

This might be easier - and would also make your figures more reusable
(for e.g. presentations).

Hope that helps,

Alex

···

On Wed, 18 Jul 2012 15:50:50 -0700 Brad Malone <brad.malone@...287...> wrote:

Hi, I have a collection of 4 plots that I spent some time in
constructing. They themselves include modifications of the axes
labels, have rotated subplots next to them, etc. I need to be able to
take these 4 plots and consolidate them into a single plot (referee
suggestion to save space).

Hi Brad,

2012/7/19 Alexander Eberspaecher <alexander.eberspaecher@...3273...>:

Hi, I have a collection of 4 plots that I spent some time in
constructing. They themselves include modifications of the axes
labels, have rotated subplots next to them, etc. I need to be able to
take these 4 plots and consolidate them into a single plot (referee
suggestion to save space).

Assuming you are using LaTeX to write your paper, you could use a LaTeX
solution. Here are some links:

http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions#Subfloats
ftp://ctan.tug.org/tex-archive/macros/latex/contrib/subfig/subfig.pdf

This might be easier - and would also make your figures more reusable
(for e.g. presentations).

The solution from Alex might work, but not being optimal in saving
space, in particular if you can share axis.

The labels (a),(b),... can be inserted in the figures with
a.text(x,y,'(a)', ... ). I know that some journals want them in the
figure and not made with latex, so you probably have to rerun your
script with the text added.

If you want to make a unique figure you can try to declare the axis
directly, insead of using subplot, and play with the rect keyword:
http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.axes
.
You can also play with gridspec
(http://matplotlib.sourceforge.net/users/gridspec.html), but I've
never used myself

Cheers,
Francesco

···

On Wed, 18 Jul 2012 15:50:50 -0700 > Brad Malone <brad.malone@...287...> wrote:

> Hi, I have a collection of 4 plots that I spent some time in
> constructing. They themselves include modifications of the axes
> labels, have rotated subplots next to them, etc. I need to be able to
> take these 4 plots and consolidate them into a single plot (referee
> suggestion to save space).

Assuming you are using LaTeX to write your paper, you could use a LaTeX
solution. Here are some links:

http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions#Subfloats
ftp://ctan.tug.org/tex-archive/macros/latex/contrib/subfig/subfig.pdf

This might be easier - and would also make your figures more reusable
(for e.g. presentations).

Personally, I use the subfigure package and it works really well. Also,
+1 for reusable figures. The downside of the subfigure package is your
latex code looks that much worse, but if the journal doesn't mind you
using the subfigure package, then I recommend it.

···

On Thu, Jul 19, 2012 at 10:23:09AM +0200, Alexander Eberspaecher wrote:

On Wed, 18 Jul 2012 15:50:50 -0700 > Brad Malone <brad.malone@...287...> wrote:

Hope that helps,

Alex

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Damon McDougall
http://damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom

I <3 the subfigure package, and I don’t think it looks “worse”. What is nice about subfigure is that I can attach labels for each subfigure, which can be referenced from the text. No, the problem with subfigure isn’t that it clutters the latex, which I don’t think it does, the problem is that some journals – ametsoc, I am looking at you! – will still count each subfigure as a separate image in the calculation for the cost of publishing.

Unfortunately, there is no (easy) way in matplotlib to re-combine axes objects into a new figure, which is what I think you are trying to do. Your best bet is to break down your code a bit into separate functions for each of the two plots that take an “ax” argument as well as pertinent input parameters. Then create your gridspec for the new configuration and loop over the subplots with an index like “for i in range(0, N*2, 2)” calling “ax = subplot(gs[i])” and “ax2 = subplot(gs[i+1])”.

I hope that helps!
Ben Root

···

On Thu, Jul 19, 2012 at 4:30 AM, Damon McDougall <damon.mcdougall@…287…> wrote:

On Thu, Jul 19, 2012 at 10:23:09AM +0200, Alexander Eberspaecher wrote:

On Wed, 18 Jul 2012 15:50:50 -0700 > > > Brad Malone <brad.malone@…120…287…> wrote:

Hi, I have a collection of 4 plots that I spent some time in

constructing. They themselves include modifications of the axes

labels, have rotated subplots next to them, etc. I need to be able to

take these 4 plots and consolidate them into a single plot (referee

suggestion to save space).

Assuming you are using LaTeX to write your paper, you could use a LaTeX

solution. Here are some links:

http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions#Subfloats

ftp://ctan.tug.org/tex-archive/macros/latex/contrib/subfig/subfig.pdf

This might be easier - and would also make your figures more reusable

(for e.g. presentations).

Personally, I use the subfigure package and it works really well. Also,

+1 for reusable figures. The downside of the subfigure package is your

latex code looks that much worse, but if the journal doesn’t mind you

using the subfigure package, then I recommend it.