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 that helps,
Sterling
On Nov 16, 2012, at 7:46AM, ChaoYue wrote:
> 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):
> cbar_label.append("{0}-{1}".format(cbarlevel[i],cbarlevel[i+1]))
> cbar_label.append('')
>
> In [54]: print cbar_label
> ['0-10', '10-20', '20-30', '30-40', '40-50', '50-60', '60-70', '70-80',
> '80-90', '90-100', '']
>
> #Then to apply on the colorbar:
> cbar.set_ticklabels(cbar_label)
>
> The generated figure is attached. But how can I put the labels a little bit
> upward to make them parallel with the respective small rectangles in the
> colorbar? <http://matplotlib.1069221.n5.nabble.com/file/n39786/fig.jpg>
>
>
>
>
>
> --
> View this message in context:
> http://matplotlib.1069221.n5.nabble.com/how-to-put-colorbar-label-beside-the-handle-tp39705p39786.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov
> _______________________________________________
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users