Re: [Matplotlib-users] how to put colorbar label beside the handle?

2012-12-04 Thread ChaoYue
Hi, rather than the previous manual definition of the text postioins, I find a more general/decent way: yloc=(cbar.values-cbar.boundaries[0])/(cbar.boundaries[-1]-cbar.boundaries[0]) for l,y in zip(cbar_label,yloc): cbar.ax.text(1,y,l,transform=cbar.ax.transAxes,ha='left',va='center') Chao

Re: [Matplotlib-users] how to put colorbar label beside the handle?

2012-11-19 Thread Sterling Smith
Chao, I'm glad you were able to get what you wanted. I don't know how to add anything to the gallery. -Sterling On Nov 17, 2012, at 3:32AM, Chao YUE wrote: Hi Sterling, Thanks for the help. Now we have a complete script that works as what we want: labels parallel with the

Re: [Matplotlib-users] how to put colorbar label beside the handle?

2012-11-17 Thread Chao YUE
Hi Sterling, Thanks for the help. Now we have a complete script that works as what we want: labels parallel with the colorbar with colorbar seperated By the way, is it possible to put in the gallery? from pylab import * a = np.arange(100).reshape(10,10) cbarlevel=np.arange(0,101,10)

Re: [Matplotlib-users] how to put colorbar label beside the handle?

2012-11-16 Thread ChaoYue
I have a bit progress, but still not very well. #to have a contourf plot a = np.arange(100).reshape(10,10) cbarlevel=np.arange(0,101,10) contourf(a,levels=cbarlevel) cbar = colorbar() cbar.set_ticks(cbarlevel) #to manipulate the range: cbar_label = [] for i in range(len(cbarlevel)-1):

Re: [Matplotlib-users] how to put colorbar label beside the handle?

2012-11-16 Thread Sterling Smith
Chao, The secret is positioning your ticks. I list here an untested attempt at putting the labels at the average of the current and next levels: cbar.set_ticks((cbarlevel[1:]+cbarlevel[:-1])/2.) Because you have less ticks, then you will want to remove the line cbar_level.append('') Hope

Re: [Matplotlib-users] how to put colorbar label beside the handle?

2012-11-16 Thread Sterling Smith
Chao, If you don't need the tick marks and are only annoyed by their appearance in the colorbar, then I am pasting below our code so far setting the tick length to 0. Code so far: from pylab import * fig = figure(2) fig.clear() a = np.arange(100).reshape(10,10) cbarlevel=np.arange(0,101,10)

Re: [Matplotlib-users] how to put colorbar label beside the handle?

2012-11-10 Thread Paul Hobson
On Sat, Nov 10, 2012 at 6:25 AM, Chao YUE chaoyue...@gmail.com wrote: Dear all, In the colorbar label for contourf or imshow plot, I want the effect like that in the attached figure. Is there some way to move the position of colorbar label? could someone give any hints? Chao, It's not