range in the colorbar

Hi,

I am generating a scatter plot with a colorbar, and want to pass on the colorbar to some function to do something with it, like

plt.scatter(px, py, c=pz, …)
cb = plt.colorbar()
foo(cb)

My question: How can I extract the range of the colorbar from the cb object? The colorbar extends from min(pz) to max(pz), but can I access these values from the cb object alone, without the need to pass pz to foo as well?

Thanks
Alex

Hi,

I am generating a scatter plot with a colorbar, and want to pass on the
colorbar to some function to do something with it, like

plt.scatter(px, py, c=pz, ...)
cb = plt.colorbar()
foo(cb)

My question: How can I extract the range of the colorbar from the cb
object? The colorbar extends from min(pz) to max(pz), but can I access
these values from the cb object alone, without the need to pass pz to
foo as well?

cb.norm.vmin
cb.norm.vmax

Or you can get the same thing from the collection returned by scatter:

col = scatter(...)
col.norm.vmin
col.norm.vmax

The colorbar uses the norm and colormap from the current image (or more generally, the color-mappable object), which in this case is the collection generated by scatter().

Eric

···

On 10/20/2010 11:41 PM, Alexander Dietz wrote:

Thanks
   Alex

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps& games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hi Eric,

thanks a lot, that was exactly I was looking for…

Alex

···

On Thu, Oct 21, 2010 at 20:23, Eric Firing <efiring@…202…> wrote:

On 10/20/2010 11:41 PM, Alexander Dietz wrote:

Hi,

I am generating a scatter plot with a colorbar, and want to pass on the

colorbar to some function to do something with it, like

plt.scatter(px, py, c=pz, …)

cb = plt.colorbar()

foo(cb)

My question: How can I extract the range of the colorbar from the cb

object? The colorbar extends from min(pz) to max(pz), but can I access

these values from the cb object alone, without the need to pass pz to

foo as well?

cb.norm.vmin

cb.norm.vmax

Or you can get the same thing from the collection returned by scatter:

col = scatter(…)

col.norm.vmin

col.norm.vmax

The colorbar uses the norm and colormap from the current image (or more

generally, the color-mappable object), which in this case is the

collection generated by scatter().

Eric

Thanks

Alex


Nokia and AT&T present the 2010 Calling All Innovators-North America contest

Create new apps& games for the Nokia N8 for consumers in U.S. and Canada

$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing

Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store

http://p.sf.net/sfu/nokia-dev2dev


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

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


Nokia and AT&T present the 2010 Calling All Innovators-North America contest

Create new apps & games for the Nokia N8 for consumers in U.S. and Canada

$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing

Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store

http://p.sf.net/sfu/nokia-dev2dev


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

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