From: James Boyle <boyle5@ll...> - 2004-03-01 22:51:49
I was making subplots using the bar command and ran into a problem I do
nr = number of rows, nc = number of columns
I want nr = 1, i.e. just one row of plots. If nc is 1 or 2 all is
well, but nc =3 the third plot is cutoff in the middle. If nc = 4, I
get 3 plots and the fourth cannot be seen.
What seems to be happening is that the subplots are not scaled to fit
the viewport dictated by suplot(nr,nc,plotNumber).
I have used nc = 3 or 4 if I use the plot command and all the plots
are squished into the subregions for which I asked - even if things get
I use the PS and Agg backends and both yield similar results.
My code is below.
Thanks for any help.
from matplotlib.matlab import *
nTypes = 3
ind = arange(nTypes) # the x locations for the groups
width = .2 # the width of the bars
nr = 1
nc = 3
crap = 
for c in range(nc):
for r in range(nr):
subplotID = nc*r + c + 1
ax = subplot(nr,nc,subplotID)
frame = ax.get_frame()
amip = (20, 35, 30)
p1 = bar(ind, amip, width, color='r')
climo = (25, 32, 34)
p2 = bar(ind+width, climo, width, color='y')
isccp = (5, 10, 60)
p3 = bar(ind+2.0*width, isccp, width, color='g')
atlas = (20, 40, 70)
p4 = bar(ind+3.0*width, atlas, width, color='b')
ylabel('Cloud Fraction (%)')
title('Cloud' + str(subplotID)+'_'+str(c)+'_'+str(r) )
set(gca(), 'xticks', ind+2*width)
set(gca(), 'xticklabels', ('low', 'mid', 'high') )
set(gca(), 'yticks', arange(0,100,10))
legend( (p1, p2,p3,p4), ('Amip',
From: John Hunter <jdhunter@ac...> - 2004-03-01 23:47:37
>>>>> "James" == James Boyle <boyle5@...> writes:
James> I have used nc = 3 or 4 if I use the plot command and all
James> the plots are squished into the subregions for which I
James> asked - even if things get ugly.
This is a one character bug!
I mainly use multiple rows in my own plots and never noticed it. On
or around line 1492 in axes.Subplot.__init__
figLeft = left + colNum*(figW + sepH)
figLeft = left + colNum*(figW + sepW)
Thanks for the detailed bug report and example code.