How to put the label above horizontal colorbar?

Dear all,

I am using the matplotlib 1.2.0 version, is there some way to put the
label above the horizontal colorbar? like in the attached example, I would
like the labels to be shown above the colorbar?

thanks a lot in advance,

Cheers,

Chao

eg3.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


Dear Chao,

You could try this,

import matplotlib

import matplotlib.pyplot as plt

create a color bar with:

sm = plt.cm.ScalarMappable(cmap=plt.get_cmap(‘Reds’))

sm.set_array(range(10))

create an horizontal colorbar and put the ticks on the top.

in your case, you could plot colorbar on top, and tick at ‘bottom’

cb = plt.colorbar(sm, orientation=‘horizontal’, location=1.0)

cb.ax.xaxis.set_ticks_position(‘top’)

plt.show()

Another way, you could find useful a function written by Ryan May [0]

Hope that fits.

Arnaldo.

[0] https://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg07447.html

···

Instituto de Oceanografia - FURG


Arnaldo D’Amaral Pereira Granja Russo
Lab. de Estudos dos Oceanos e Clima

2014-03-10 14:39 GMT-03:00 Chao YUE <chaoyuejoy@…287…>:

Dear all,


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


I am using the matplotlib 1.2.0 version, is there some way to put the
label above the horizontal colorbar? like in the attached example, I would
like the labels to be shown above the colorbar?

thanks a lot in advance,

Cheers,

Chao


Learn Graph Databases - Download FREE O’Reilly Book

“Graph Databases” is the definitive new guide to graph databases and their

applications. Written by three acclaimed leaders in the field,

this first edition is now available. Download your free book today!

http://p.sf.net/sfu/13534_NeoTech


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Dear Arnaldo,

sorry for the delay in reply. Thanks a lot. This solves my problem well.

Cheers,

Chao

···

On Sun, Mar 16, 2014 at 7:27 AM, Arnaldo Russo <arnaldorusso@…1896…> wrote:

Dear Chao,

You could try this,

import matplotlib

import matplotlib.pyplot as plt

create a color bar with:

sm = plt.cm.ScalarMappable(cmap=plt.get_cmap(‘Reds’))

sm.set_array(range(10))

create an horizontal colorbar and put the ticks on the top.

in your case, you could plot colorbar on top, and tick at ‘bottom’

cb = plt.colorbar(sm, orientation=‘horizontal’, location=1.0)

cb.ax.xaxis.set_ticks_position(‘top’)

plt.show()

Another way, you could find useful a function written by Ryan May [0]

Hope that fits.

Arnaldo.

[0] https://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg07447.html


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


Instituto de Oceanografia - FURG


Arnaldo D’Amaral Pereira Granja Russo
Lab. de Estudos dos Oceanos e Clima

2014-03-10 14:39 GMT-03:00 Chao YUE <chaoyuejoy@…287…>:

Dear all,


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


I am using the matplotlib 1.2.0 version, is there some way to put the
label above the horizontal colorbar? like in the attached example, I would
like the labels to be shown above the colorbar?

thanks a lot in advance,

Cheers,

Chao


Learn Graph Databases - Download FREE O’Reilly Book

“Graph Databases” is the definitive new guide to graph databases and their

applications. Written by three acclaimed leaders in the field,

this first edition is now available. Download your free book today!

http://p.sf.net/sfu/13534_NeoTech


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users