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

2012-11-10 Thread Chao YUE
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

attachment: label.jpg--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] how to reverse the colorbar and its label at the same time?

2012-11-10 Thread Chao YUE
Dear all,

Is there a way to reverse the colorbar label, the default is small value at
the bottom and big value at the top, yet I would like the big value at the
bottom and small value at the top.

all code in pylab mode.

import numpy as np
import matplotlib as mat

a = np.arange(100).reshape(10,10)
contourf(a,levels=np.arange(0,101,10))
colorbar()

in the above figure, colorbar label shows 0 at the bottom and 100 at the
top.
Yet I want the 0 at the top and the 100 at the bottom, with the same
sequence of colors in the colorbar.

One way is to reverse the cmap, and then reverse the colorbar labels at the
same time:
a = np.arange(100).reshape(10,10)
contourf(a,levels=np.arange(0,101,10),cmap=mat.cm.jet_r)
cbar = colorbar()
cbar.set_ticks(np.arange(0,101,10))
cbar.set_ticklabels(np.arange(100,-1,-10))

But the problem is, sometimes I used the customized colormap, and to
increase the contrast, I do linear transformation for the data before I
plot them.
The the data that are really used for plotting are not the same. But in the
colorbar label, I used the values before transformation. Is this
complicated case,
reverse the customized colormap could not solve the problem (unlike in the
simple example above.) Does anyone have the same experience?

Thanks et cheers,

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

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colormap shift

2012-11-10 Thread ChaoYue
Hi, I once was indicated a way to extract colors from exsiting colormaps:

I just answered a question on Stackoverflow and maybe you can have a look.

all code in pylab mode

a = np.arange(100).reshape(10,10)
#here is the image with white and black end
imshow(a,cmap=mat.cm.binary)
colorbar()

#we extract only the 0.2--0.7 part of original colormap and make a new one
#so that the white and black end are removed
rgba_array = mat.cm.binary(np.linspace(0,1,num=10,endpoint=True))
extract_rgba_array_255 = rgba_array[2:8,0:3]
imshow(a,cmap=mat.colors.ListedColormap(extract_rgba_array_255))
colorbar()

cheers,

Chao




--
View this message in context: 
http://matplotlib.1069221.n5.nabble.com/colormap-shift-tp39660p39707.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] how to reverse the colorbar and its label at the same time?

2012-11-10 Thread Paul Hobson
On Sat, Nov 10, 2012 at 7:07 AM, Chao YUE chaoyue...@gmail.com wrote:

 Dear all,

 Is there a way to reverse the colorbar label, the default is small value at 
 the bottom and big value at the top, yet I would like the big value at the 
 bottom and small value at the top.

 all code in pylab mode.

 import numpy as np
 import matplotlib as mat

 a = np.arange(100).reshape(10,10)
 contourf(a,levels=np.arange(0,101,10))
 colorbar()

 in the above figure, colorbar label shows 0 at the bottom and 100 at the top.
 Yet I want the 0 at the top and the 100 at the bottom, with the same sequence 
 of colors in the colorbar.

 One way is to reverse the cmap, and then reverse the colorbar labels at the 
 same time:
 a = np.arange(100).reshape(10,10)
 contourf(a,levels=np.arange(0,101,10),cmap=mat.cm.jet_r)
 cbar = colorbar()
 cbar.set_ticks(np.arange(0,101,10))
 cbar.set_ticklabels(np.arange(100,-1,-10))

Chao,

I think it's as simple as:

import numpy as np
import matplotlib.pyplot as plt

a = np.arange(100).reshape(10,10)
fig, ax1 = plt.subplots()
CS = ax1.contourf(a,levels=np.arange(0,101,10))
cbar = plt.colorbar(CS)
cbar.ax.invert_yaxis()

Does that produce the desired results?
-p

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] how to reverse the colorbar and its label at the same time?

2012-11-10 Thread Damon McDougall
On Sat, Nov 10, 2012 at 9:41 AM, Paul Hobson pmhob...@gmail.com wrote:
 On Sat, Nov 10, 2012 at 7:07 AM, Chao YUE chaoyue...@gmail.com wrote:

 Dear all,

 Is there a way to reverse the colorbar label, the default is small value at 
 the bottom and big value at the top, yet I would like the big value at the 
 bottom and small value at the top.

 all code in pylab mode.

 import numpy as np
 import matplotlib as mat

 a = np.arange(100).reshape(10,10)
 contourf(a,levels=np.arange(0,101,10))
 colorbar()

 in the above figure, colorbar label shows 0 at the bottom and 100 at the top.
 Yet I want the 0 at the top and the 100 at the bottom, with the same 
 sequence of colors in the colorbar.

 One way is to reverse the cmap, and then reverse the colorbar labels at the 
 same time:
 a = np.arange(100).reshape(10,10)
 contourf(a,levels=np.arange(0,101,10),cmap=mat.cm.jet_r)
 cbar = colorbar()
 cbar.set_ticks(np.arange(0,101,10))
 cbar.set_ticklabels(np.arange(100,-1,-10))

 Chao,

 I think it's as simple as:

 import numpy as np
 import matplotlib.pyplot as plt

 a = np.arange(100).reshape(10,10)
 fig, ax1 = plt.subplots()
 CS = ax1.contourf(a,levels=np.arange(0,101,10))
 cbar = plt.colorbar(CS)
 cbar.ax.invert_yaxis()

 Does that produce the desired results?
 -p

Or, you could plot -a instead of a.

-- 
Damon McDougall
http://www.damon-is-a-geek.com
Institute for Computational Engineering Sciences
201 E. 24th St.
Stop C0200
The University of Texas at Austin
Austin, TX 78712-1229

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


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

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] how to reverse the colorbar and its label at the same time?

2012-11-10 Thread Chao YUE
Thanks, I think cbar.ax.invert_yaxis() is what I am looking for.

Chao

On Sat, Nov 10, 2012 at 4:51 PM, Damon McDougall
damon.mcdoug...@gmail.comwrote:

 On Sat, Nov 10, 2012 at 9:41 AM, Paul Hobson pmhob...@gmail.com wrote:
  On Sat, Nov 10, 2012 at 7:07 AM, Chao YUE chaoyue...@gmail.com wrote:
 
  Dear all,
 
  Is there a way to reverse the colorbar label, the default is small
 value at the bottom and big value at the top, yet I would like the big
 value at the bottom and small value at the top.
 
  all code in pylab mode.
 
  import numpy as np
  import matplotlib as mat
 
  a = np.arange(100).reshape(10,10)
  contourf(a,levels=np.arange(0,101,10))
  colorbar()
 
  in the above figure, colorbar label shows 0 at the bottom and 100 at
 the top.
  Yet I want the 0 at the top and the 100 at the bottom, with the same
 sequence of colors in the colorbar.
 
  One way is to reverse the cmap, and then reverse the colorbar labels at
 the same time:
  a = np.arange(100).reshape(10,10)
  contourf(a,levels=np.arange(0,101,10),cmap=mat.cm.jet_r)
  cbar = colorbar()
  cbar.set_ticks(np.arange(0,101,10))
  cbar.set_ticklabels(np.arange(100,-1,-10))
 
  Chao,
 
  I think it's as simple as:
 
  import numpy as np
  import matplotlib.pyplot as plt
 
  a = np.arange(100).reshape(10,10)
  fig, ax1 = plt.subplots()
  CS = ax1.contourf(a,levels=np.arange(0,101,10))
  cbar = plt.colorbar(CS)
  cbar.ax.invert_yaxis()
 
  Does that produce the desired results?
  -p

 Or, you could plot -a instead of a.

 --
 Damon McDougall
 http://www.damon-is-a-geek.com
 Institute for Computational Engineering Sciences
 201 E. 24th St.
 Stop C0200
 The University of Texas at Austin
 Austin, TX 78712-1229




-- 
***
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

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users