I solved this problem using pyplot and the following code:
x = np.arange(22)
y = x
window = 1
tsize = 8
plt.clf()
plt.cla()
nrow = 0
for k in np.sort(dlist.keys()): # 2d data arrays of size (x,y)
if not doplot[k]: continue
vdic = dlist[k]
for v in np.sort(vdic.keys()):
plt.subplot(self.rows,self.cols,window)
if vlist[k] == 'RR':
plt.title(v,fontsize=tsize)
plt.subplots_adjust(bottom=0.26,left=0.18, # These
values are taken from the GUI
right=.90, top=0.94, #
window after I adjusted the fig to my liking
wspace=0.07,hspace=0.94)
cs = plt.contourf(x,y,vdic[v],levels[k],cmap=
cm.get_cmap('jet',len(levels[k])-1))
plt.axis('off')
window += 1
ax = plt.gca()
pos = ax.get_position()
l,b,w,h = pos.bounds
print l,b,w,h
cax = plt.axes([l-0.668,b-0.02,0.719,0.01]) # setup colorbar
axes
cbar = plt.colorbar(cs,cax=cax,orientation='horizontal')
cl = plt.getp(cbar.ax, 'xticklabels')
plt.setp(cl, fontsize=8)
fx = 0.07
fy = 0.9
dy = 0.15
yp = fy - (dy*nrow)
plt.figtext(fx,yp,units[k],fontsize=tsize+1)
nrow += 1
#pdb.set_trace() # debugging python -m file.py
cmd = '%s%s%s' % ('ece3_',win,'_L91.pdf')
plt.savefig(cmd,dpi=600,orientation='landscape')
I also attached an example.
Marston wrote:
>
> Hi,
>
> I'm trying to create a plot, with subplots where each row of x plots have
> a common colorbar beneath it. Only the the top row will have titles. I've
> tried creating a function to do this but I only achieve partial success.
> Here is an image created in another program that I want to duplicate:
>
> http://old.nabble.com/file/p33544950/fig.jpg fig.jpg
>
> I made several functions to do this. Here's one of them:
>
> def Plot(self,title,plist):
> for k in np.sort(self.vdic.keys()):
>
> plt.subplot(5,13,self.window)
>
> cs = plt.contourf(22,22,np.squeeze(self.vdic[k]),plist['levels'],
>
> cmap=cm.get_cmap('jet',len(plist['levels'])-1))
>
> plt.axis('off')
>
> if title: plt.title(k,fontsize=tsize)
>
> window += 1
> cbar = plt.colorbar(cax=plist['cax'],orientation='h')
>
>
> I've given up in getting the text on the left because every attempt using
> text fails.
> Now if this is a horrible way and you have a better idea, please feel free
> to share.
> I'm new at matplotlib and this is a great way to see how things can be
> done better
> and in different ways.
>
--
View this message in context:
http://old.nabble.com/Subplot-array-and-colorbar-tp33544950p33568733.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users