|
From: Chao Y. <cha...@gm...> - 2012-11-10 14:25:34
Attachments:
label.jpg
|
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? Thanks! Chao -- *********************************************************************************** Chao YUE Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL) UMR 1572 CEA-CNRS-UVSQ Batiment 712 - Pe 119 91191 GIF Sur YVETTE Cedex Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16 ************************************************************************************ |
|
From: Paul H. <pmh...@gm...> - 2012-11-10 15:53:38
|
On Sat, Nov 10, 2012 at 6:25 AM, Chao YUE <cha...@gm...> 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 clear what you mean. What's distinctive about the image you attached? Is it: - The ranges of values listed to the side? - The discrete blocks for each value range? - The units being listed above the colorbar? I think I can help you do any of those things. I just need to know what you're specifically trying to do. -paul |
|
From: Chao Y. <cha...@gm...> - 2012-11-10 16:36:14
Attachments:
figure_1.jpg
|
Thanks a lot Paul. Oh, I even didn't think about the second point raised by you. but it would be great to have. The main point is the first point raised by you, I just didn't know how to put the label (in the example figure it's value range) exactly beside the colorbar. In the attached figure you can see the labels (here the label is a number) are put at the place of connection interface of two different colors but not beside the colorbar. like for the first top blue block, I would like to have 0-10 beside it, but not to put 0 at the top and 10 at the bottom. I hope I am clear. The code that generate attached figure is here: a = np.arange(100).reshape(10,10) contourf(a,levels=np.arange(0, 101,10)) cbar = colorbar() cbar.set_ticks(np.arange(0,101,10)) cbar.set_ticklabels(np.arange(0,101,10)) could you please indicate how can I have the first and second points raised by you? thanks a lot! Chao On Sat, Nov 10, 2012 at 4:53 PM, Paul Hobson <pmh...@gm...> wrote: > On Sat, Nov 10, 2012 at 6:25 AM, Chao YUE <cha...@gm...> 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 clear what you mean. What's distinctive about the image you > attached? Is it: > - The ranges of values listed to the side? > - The discrete blocks for each value range? > - The units being listed above the colorbar? > > I think I can help you do any of those things. I just need to know > what you're specifically trying to do. > -paul > -- *********************************************************************************** Chao YUE Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL) UMR 1572 CEA-CNRS-UVSQ Batiment 712 - Pe 119 91191 GIF Sur YVETTE Cedex Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16 ************************************************************************************ |
|
From: ChaoYue <cha...@gm...> - 2012-11-16 15:46:35
|
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.
|
|
From: Sterling S. <sm...@fu...> - 2012-11-16 16:47:41
|
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
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
|
|
From: Sterling S. <sm...@fu...> - 2012-11-16 23:12:42
|
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)
contourf(a,levels=cbarlevel)
cbar = colorbar()
cbar.set_ticks((cbarlevel[1:]+cbarlevel[:-1])/2.)
#to manipulate the range:
cbar_label = []
for i in range(len(cbarlevel)-1):
cbar_label.append("{0}-{1}".format(cbarlevel[i],cbarlevel[i+1]))
#Then to apply on the colorbar:
cbar.set_ticklabels(cbar_label)
ax = fig.axes[-1] #This is not as clean as making the axes before the colorbar and passing to the colorbar...
ax.yaxis.set_tick_params(length=0)
If you still want the ticks, then you might think of keeping the ticks where you had set them originally, then placing texts (pylab.text) with the transAxes transform, using the following script:
from pylab import *
fig = figure(2)
fig.clear()
a = np.arange(100).reshape(10,10)
cbarlevel=np.arange(0,101,10)
contourf(a,levels=cbarlevel)
cbar = colorbar()
#cbar.set_ticks((cbarlevel[1:]+cbarlevel[:-1])/2.)
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('')
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(['']*len(cbarlevel))
ax = fig.axes[-1]
#ax.yaxis.set_tick_params(length=0)
yloc = linspace(0,1,len(cbar_label)+1)
yloc = yloc[:-1] + yloc[1]/2.
for l,y in zip(cbar_label,yloc):
ax.text(1,y,l,transform=ax.transAxes,ha='left')
draw()
-Sterling
On Nov 16, 2012, at 12:58PM, Chao YUE wrote:
> Thanks Sterling. It's a good idea.
>
> Unluckily, I lose the original ticks and the ticks appeared in the middle. Is there any approach I can keep the original ticks while realizing what has been shown in the figure?
>
> Chao
>
> On Fri, Nov 16, 2012 at 5:47 PM, Sterling Smith <sm...@fu...> wrote:
> 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
> > Mat...@li...
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
>
> --
> ***********************************************************************************
> Chao YUE
> Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
> UMR 1572 CEA-CNRS-UVSQ
> Batiment 712 - Pe 119
> 91191 GIF Sur YVETTE Cedex
> Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
> ************************************************************************************
>
> <fig.jpg>
|
|
From: Chao Y. <cha...@gm...> - 2012-11-17 11:32:51
|
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)
cs=contourf(a,levels=cbarlevel)
cbar = colorbar()
cbar.set_ticks(cbarlevel)
#prepare the final label that we want
cbar_label = []
for i in range(len(cbarlevel)-1):
cbar_label.append(" {0}-{1}".format(cbarlevel[i],cbarlevel[i+1]))
cbar.set_ticklabels(['']*len(cbarlevel)) #remove the original labels
#set ticks as white; the 'length' parameter is a bit dirty solution
cbar.ax.tick_params(axis='y',left='on',length=10,color='w',width=5)
cbar.outline.remove() #remove the colorbar frame
#add the label parallel to colorbar; 0.035 to be set by manual observation,
a bit dirty solution.
yloc=np.arange(0.035,0.95,0.1)
for l,y in zip(cbar_label,yloc):
cbar.ax.text(1,y,l,transform=cbar.ax.transAxes,ha='left')
cheers,
Chao
On Sat, Nov 17, 2012 at 12:12 AM, Sterling Smith <sm...@fu...>wrote:
> 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)
> contourf(a,levels=cbarlevel)
> cbar = colorbar()
> cbar.set_ticks((cbarlevel[1:]+cbarlevel[:-1])/2.)
>
> #to manipulate the range:
> cbar_label = []
> for i in range(len(cbarlevel)-1):
> cbar_label.append("{0}-{1}".format(cbarlevel[i],cbarlevel[i+1]))
>
> #Then to apply on the colorbar:
> cbar.set_ticklabels(cbar_label)
>
> ax = fig.axes[-1] #This is not as clean as making the axes before the
> colorbar and passing to the colorbar...
> ax.yaxis.set_tick_params(length=0)
>
>
> If you still want the ticks, then you might think of keeping the ticks
> where you had set them originally, then placing texts (pylab.text) with the
> transAxes transform, using the following script:
>
>
> from pylab import *
> fig = figure(2)
> fig.clear()
> a = np.arange(100).reshape(10,10)
> cbarlevel=np.arange(0,101,10)
> contourf(a,levels=cbarlevel)
> cbar = colorbar()
> #cbar.set_ticks((cbarlevel[1:]+cbarlevel[:-1])/2.)
> 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('')
>
> 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(['']*len(cbarlevel))
>
> ax = fig.axes[-1]
> #ax.yaxis.set_tick_params(length=0)
>
> yloc = linspace(0,1,len(cbar_label)+1)
> yloc = yloc[:-1] + yloc[1]/2.
> for l,y in zip(cbar_label,yloc):
> ax.text(1,y,l,transform=ax.transAxes,ha='left')
> draw()
>
> -Sterling
>
> On Nov 16, 2012, at 12:58PM, Chao YUE wrote:
>
> > Thanks Sterling. It's a good idea.
> >
> > Unluckily, I lose the original ticks and the ticks appeared in the
> middle. Is there any approach I can keep the original ticks while realizing
> what has been shown in the figure?
> >
> > Chao
> >
> > On Fri, Nov 16, 2012 at 5:47 PM, Sterling Smith <sm...@fu...>
> wrote:
> > 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
> > > Mat...@li...
> > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
> >
> >
> >
> > --
> >
> ***********************************************************************************
> > Chao YUE
> > Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
> > UMR 1572 CEA-CNRS-UVSQ
> > Batiment 712 - Pe 119
> > 91191 GIF Sur YVETTE Cedex
> > Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
> >
> ************************************************************************************
> >
> > <fig.jpg>
>
>
--
***********************************************************************************
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************
|
|
From: Sterling S. <sm...@fu...> - 2012-11-19 16:39:04
|
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 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)
> cs=contourf(a,levels=cbarlevel)
> cbar = colorbar()
> cbar.set_ticks(cbarlevel)
>
> #prepare the final label that we want
> cbar_label = []
> for i in range(len(cbarlevel)-1):
> cbar_label.append(" {0}-{1}".format(cbarlevel[i],cbarlevel[i+1]))
>
> cbar.set_ticklabels(['']*len(cbarlevel)) #remove the original labels
> #set ticks as white; the 'length' parameter is a bit dirty solution
> cbar.ax.tick_params(axis='y',left='on',length=10,color='w',width=5)
> cbar.outline.remove() #remove the colorbar frame
>
> #add the label parallel to colorbar; 0.035 to be set by manual observation, a bit dirty solution.
> yloc=np.arange(0.035,0.95,0.1)
> for l,y in zip(cbar_label,yloc):
> cbar.ax.text(1,y,l,transform=cbar.ax.transAxes,ha='left')
>
> cheers,
>
> Chao
>
> On Sat, Nov 17, 2012 at 12:12 AM, Sterling Smith <sm...@fu...> wrote:
> 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)
> contourf(a,levels=cbarlevel)
> cbar = colorbar()
> cbar.set_ticks((cbarlevel[1:]+cbarlevel[:-1])/2.)
>
> #to manipulate the range:
> cbar_label = []
> for i in range(len(cbarlevel)-1):
> cbar_label.append("{0}-{1}".format(cbarlevel[i],cbarlevel[i+1]))
>
> #Then to apply on the colorbar:
> cbar.set_ticklabels(cbar_label)
>
> ax = fig.axes[-1] #This is not as clean as making the axes before the colorbar and passing to the colorbar...
> ax.yaxis.set_tick_params(length=0)
>
>
> If you still want the ticks, then you might think of keeping the ticks where you had set them originally, then placing texts (pylab.text) with the transAxes transform, using the following script:
>
>
> from pylab import *
> fig = figure(2)
> fig.clear()
> a = np.arange(100).reshape(10,10)
> cbarlevel=np.arange(0,101,10)
> contourf(a,levels=cbarlevel)
> cbar = colorbar()
> #cbar.set_ticks((cbarlevel[1:]+cbarlevel[:-1])/2.)
> 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('')
>
> 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(['']*len(cbarlevel))
>
> ax = fig.axes[-1]
> #ax.yaxis.set_tick_params(length=0)
>
> yloc = linspace(0,1,len(cbar_label)+1)
> yloc = yloc[:-1] + yloc[1]/2.
> for l,y in zip(cbar_label,yloc):
> ax.text(1,y,l,transform=ax.transAxes,ha='left')
> draw()
>
> -Sterling
>
> On Nov 16, 2012, at 12:58PM, Chao YUE wrote:
>
> > Thanks Sterling. It's a good idea.
> >
> > Unluckily, I lose the original ticks and the ticks appeared in the middle. Is there any approach I can keep the original ticks while realizing what has been shown in the figure?
> >
> > Chao
> >
> > On Fri, Nov 16, 2012 at 5:47 PM, Sterling Smith <sm...@fu...> wrote:
> > 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
> > > Mat...@li...
> > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
> >
> >
> >
> > --
> > ***********************************************************************************
> > Chao YUE
> > Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
> > UMR 1572 CEA-CNRS-UVSQ
> > Batiment 712 - Pe 119
> > 91191 GIF Sur YVETTE Cedex
> > Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
> > ************************************************************************************
> >
> > <fig.jpg>
>
>
>
>
> --
> ***********************************************************************************
> Chao YUE
> Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
> UMR 1572 CEA-CNRS-UVSQ
> Batiment 712 - Pe 119
> 91191 GIF Sur YVETTE Cedex
> Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
> ************************************************************************************
>
|
|
From: ChaoYue <cha...@gm...> - 2012-12-04 21:21:05
|
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
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/how-to-put-colorbar-label-beside-the-handle-tp39705p39941.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
|