Hi,
It is quite some time ago since I was intensively using MPL. Perhaps I will not get the terminology right anymore. And now I hope to get some pointer for this particular problem:
I would like to arange some line plots using a grid from left to right in a single plot / figure instance. Each of these plots is created from vectors (numpy arrays) of a different length. If I would place subplots of equal size to place these individual plots from left to right, all will appear with a different “stretch/squeeze”.
My question now is: Is there a way to place different subplots of different sizes automatically? For all my plots I will encounter different number of individual line plots of different size.
My approach so far (pseudocode):
from mpl_toolkits.axes_grid1 import Grid
import pylab as plt
fig = plt.figure(1, (5.5, 3.5))
grid = Grid(fig, 111, # similar to subplot(111)
nrows_ncols = (1, number_of_subplots),
axes_pad = 0.1,
add_all=True,
label_mode = “L”,
)
for index in xrange(number_of_subplots):
grid[index].???
And now I just do not know how to get any further? How will I get the necessary extension for each subfigure/plot? Which is the most efficient way to accomplish all this? Should I import a different class, other than Grid?
TIA
Regards,
Christian
So, are you wanting them to all have the same x and y coordinates, or maybe you want the aspect ratio to be the same?
I am not exactly quite sure what you mean by “extension”.
Ben Root
···
On Fri, Mar 15, 2013 at 12:41 PM, Christian Meesters <meesters@…380…> wrote:
Hi,
It is quite some time ago since I was intensively using MPL. Perhaps I will not get the terminology right anymore. And now I hope to get some pointer for this particular problem:
I would like to arange some line plots using a grid from left to right in a single plot / figure instance. Each of these plots is created from vectors (numpy arrays) of a different length. If I would place subplots of equal size to place these individual plots from left to right, all will appear with a different “stretch/squeeze”.
My question now is: Is there a way to place different subplots of different sizes automatically? For all my plots I will encounter different number of individual line plots of different size.
My approach so far (pseudocode):
from mpl_toolkits.axes_grid1 import Grid
import pylab as plt
fig = plt.figure(1, (5.5, 3.5))
grid = Grid(fig, 111, # similar to subplot(111)
nrows_ncols = (1, number_of_subplots),
axes_pad = 0.1,
add_all=True,
label_mode = "L",
)
for index in xrange(number_of_subplots):
grid[index].???
And now I just do not know how to get any further? How will I get the necessary extension for each subfigure/plot? Which is the most efficient way to accomplish all this? Should I import a different class, other than Grid?
Hi David and Ben and everybody reading along,
Apparently I did not phrase my question too well.
To clarify:
I would like to have some 'subplots' with a width proportional to
the amount of (equally spaced) data points.
It seems to me that gridspec (http://matplotlib.org/users/gridspec.html)
is just the tool I need - with this I only need to calculate the
relative sizes of my subplots, but that's easy. Alas, I did not discover
it until tonight.
Thanks a lot for your help!
Christian