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
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
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)
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):
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
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)
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