Reputation: 569
I would like to have two subplots in Matplotlib (embedded in a GUI):
In both cases these are the same width.
GridSpec seems to not allow absolute sizing, only relative sizing. I don't want Subplot 1 to stretch its height with the window resizing.
How can I do this?
Upvotes: 6
Views: 1064
Reputation: 479
If I understood your question then this code might help. It uses axes instead of subplots, which give more absolute control over the position of the plots within the figure.
import pylab as pl
# use pylab.Axes(figure, [left, bottom, width, height])
# where each value in the frame is between 0 and 1
#top
figure = pl.figure()
axes = pl.Axes(figure, [.4,.4,.25,.25])
figure.add_axes(axes)
pl.plot([1, 2, 3], [1, 2, 3])
#bottom
axes = pl.Axes(figure, [.4,.1,.25,.25])
figure.add_axes(axes)
pl.plot([1, 2, 3], [1, 2, 3])
pl.show()
If this is not what you meant, please post a snippet of code or an example to clarify.
Upvotes: 1