Re: [Matplotlib-users] Colorbar interfering with figure

2012-02-15 Thread Benjamin Root
On Mon, Feb 13, 2012 at 10:38 AM, Bruce Ford br...@clearscienceinc.comwrote:

 I have a application that plots figures on demand.  I'm running into an
 issue when plotting more than one parameter on a figure.  Each parameter is
 run through libraries that I've written that make decisions and eventually
 plots the figure.  However, for some figures (when two parameters are
 plotted), the colorbar plots atop the main figure (see the attached).

 I think the reason is that each time through the libraries, a separate
 basemap is created (although with the same values) but for the first
 parameter, a colorbar is plotted and for the second, there will never be a
 colorbar.  So the final figure plots the colorbar on top.

 is there a way to test the gca() to see if a basemap has been created, or
 to detect whether the gcs() has a colorbar and leave the map/figure alone.
  (I'm not exactly sure if it's the re-creation of the basemap or the fact
 that the second parameter will not contain a colorbar that is the issue.)

 Anyone crossed this bridge?

 Bruce


What is creating a colorbar?  My usual coding style is such that any
functions I make to do complicated plots do not do any more than is
necessary.  All axis limits, title setting and colorbar making are left for
the caller of the plotting function.

From your description, it is hard to tell if the bug is in your code,
basemap, or some other third-party library.  Could you please clarify?

Cheers!
Ben Root

P.S. - Furthermore, I *really* like using the axes_grid1 toolkit because I
can specify if I want space pre-allocated for colorbars.  This way, when I
create my colorbar, I can pass the pre-allocated axes object that was made
just for the colorbar.
--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar on each subplot

2012-01-07 Thread Jae-Joon Lee
Please post a complete (but simple) example that we can easily test.
Doing the *subplot_adjust* will mess up the location of colorbars, but
I believe that colorbars should be still there.
If you're using v1.1 and later, see if using the use_gridspec
parameter works. For example,

colorbar(use_gridspec=True)

Regards,

-JJ


On Sat, Jan 7, 2012 at 8:34 PM, davcra dcdavem...@gmail.com wrote:

 Hi, I need to add a colorbar to each plot in a subplot but cant seem to get
 it to work. My code is as follows,

 # Plot time series of slowness, baz, abs.power and rel.power
 labels = 'rel.power abs.power baz slow'.split()

 fig = plt.figure()
 for i, lab in enumerate(labels):
    ax = fig.add_subplot(4, 1, i + 1)
    ax.scatter(out[:, 0], out[:, i + 1], c=out[:, 1], alpha=0.6,
               edgecolors='none')
    ax.set_ylabel(lab)
    colorbar()
 fig.autofmt_xdate()
 fig.subplots_adjust(top=0.95, right=0.95, bottom=0.2, hspace=0.25)
 plt.show()

 Dont get any error but the colorbar is missing from the plot, anyone know
 how it is done
 --
 View this message in context: 
 http://old.nabble.com/Colorbar-on-each-subplot-tp33098035p33098035.html
 Sent from the matplotlib - users mailing list archive at Nabble.com.


 --
 Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
 infrastructure or vast IT resources to deliver seamless, secure access to
 virtual desktops. With this all-in-one solution, easily deploy virtual
 desktops for less than the cost of PCs and save 60% on VDI infrastructure
 costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar on each subplot

2012-01-07 Thread Benjamin Root
On Saturday, January 7, 2012, Jae-Joon Lee lee.j.j...@gmail.com wrote:
 Please post a complete (but simple) example that we can easily test.
 Doing the *subplot_adjust* will mess up the location of colorbars, but
 I believe that colorbars should be still there.
 If you're using v1.1 and later, see if using the use_gridspec
 parameter works. For example,

 colorbar(use_gridspec=True)

 Regards,

 -JJ



Personally, I just simply use the AxesGrid1 toolkit which automatically
allocates space for colorbars if I tell it to.  Very easy to use.

Ben Root
--
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar labels never appear vertically

2011-08-19 Thread Eric Firing
On 08/18/2011 09:53 PM, James McMurray wrote:
 Hi,

 I am having a problem where the colorbar labels will never appear
 vertically, even when their rotation is specified as vertical. As you
 can see in the screenshot here: http://minus.com/lbOJyOljH  this creates
 problems when the labels are cut off and generally looks unprofessional.

 I am creating the colorbars with code like:
  cbar1.set_label(Lifetime [$\mu$s], rotation='vertical')

I don't understand; even with no kwarg, the label on a vertical colorbar 
will be vertical.  It has been that way for as long as I can remember.

What mpl version are you using?
Please provide a minimal standalone script showing the problem.

Eric




 And yet the specified rotation has no effect.

 Any help would be much appreciated,
 James



 --
 Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
 user administration capabilities and model configuration. Take
 the hassle out of deploying and managing Subversion and the
 tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2



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


--
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar labels never appear vertically

2011-08-19 Thread James McMurray
I made this standalone script here: http://pastebin.com/AnKeCwiU and this
does not suffer from the issue. For comparison here is the plotting function
in my program: http://pastebin.com/7xxtPQYb

The only major difference is the use of the interactive display in the
script, against the use of Figure and the GTK canvas in my application.

I am using matplotlib 1.0.1

On 19 August 2011 10:28, Eric Firing efir...@hawaii.edu wrote:

 On 08/18/2011 09:53 PM, James McMurray wrote:
  Hi,
 
  I am having a problem where the colorbar labels will never appear
  vertically, even when their rotation is specified as vertical. As you
  can see in the screenshot here: http://minus.com/lbOJyOljH  this creates
  problems when the labels are cut off and generally looks unprofessional.
 
  I am creating the colorbars with code like:
   cbar1.set_label(Lifetime [$\mu$s], rotation='vertical')

 I don't understand; even with no kwarg, the label on a vertical colorbar
 will be vertical.  It has been that way for as long as I can remember.

 What mpl version are you using?
 Please provide a minimal standalone script showing the problem.

 Eric



 
  And yet the specified rotation has no effect.
 
  Any help would be much appreciated,
  James
 
 
 
 
 --
  Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
  user administration capabilities and model configuration. Take
  the hassle out of deploying and managing Subversion and the
  tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
 
 
 
  ___
  Matplotlib-users mailing list
  Matplotlib-users@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/matplotlib-users



 --
 Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
 user administration capabilities and model configuration. Take
 the hassle out of deploying and managing Subversion and the
 tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar labels never appear vertically

2011-08-19 Thread James McMurray
After some testing, it appears to be caused by the use of LaTeX in the
labels which then prevents it from being rotated (but only inside the GTK
application). I have no idea why this is only occurring when it is not in
interactive mode, but I guess for the time being I can just try not to use
LaTeX.

On 19 August 2011 10:57, James McMurray jamesmc...@gmail.com wrote:

 I made this standalone script here: http://pastebin.com/AnKeCwiU and this
 does not suffer from the issue. For comparison here is the plotting function
 in my program: http://pastebin.com/7xxtPQYb

 The only major difference is the use of the interactive display in the
 script, against the use of Figure and the GTK canvas in my application.

 I am using matplotlib 1.0.1


 On 19 August 2011 10:28, Eric Firing efir...@hawaii.edu wrote:

 On 08/18/2011 09:53 PM, James McMurray wrote:
  Hi,
 
  I am having a problem where the colorbar labels will never appear
  vertically, even when their rotation is specified as vertical. As you
  can see in the screenshot here: http://minus.com/lbOJyOljH  this
 creates
  problems when the labels are cut off and generally looks unprofessional.
 
  I am creating the colorbars with code like:
   cbar1.set_label(Lifetime [$\mu$s], rotation='vertical')

 I don't understand; even with no kwarg, the label on a vertical colorbar
 will be vertical.  It has been that way for as long as I can remember.

 What mpl version are you using?
 Please provide a minimal standalone script showing the problem.

 Eric



 
  And yet the specified rotation has no effect.
 
  Any help would be much appreciated,
  James
 
 
 
 
 --
  Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
  user administration capabilities and model configuration. Take
  the hassle out of deploying and managing Subversion and the
  tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
 
 
 
  ___
  Matplotlib-users mailing list
  Matplotlib-users@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/matplotlib-users



 --
 Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
 user administration capabilities and model configuration. Take
 the hassle out of deploying and managing Subversion and the
 tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users



--
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar labels never appear vertically

2011-08-19 Thread Eric Firing
On 08/18/2011 10:57 PM, James McMurray wrote:
 I made this standalone script here: http://pastebin.com/AnKeCwiU and
 this does not suffer from the issue. For comparison here is the plotting
 function in my program: http://pastebin.com/7xxtPQYb

The problem is that the Gtk backend does not support text rotation.  If 
you use FigureCanvasGTKAgg instead of FigureCanvasGTK, I think the 
behavior will be back to normal.  The Gtk backend is not fully 
functional or supported.

Eric


 The only major difference is the use of the interactive display in the
 script, against the use of Figure and the GTK canvas in my application.

 I am using matplotlib 1.0.1

 On 19 August 2011 10:28, Eric Firing efir...@hawaii.edu
 mailto:efir...@hawaii.edu wrote:

 On 08/18/2011 09:53 PM, James McMurray wrote:
   Hi,
  
   I am having a problem where the colorbar labels will never appear
   vertically, even when their rotation is specified as vertical.
 As you
   can see in the screenshot here: http://minus.com/lbOJyOljH  this
 creates
   problems when the labels are cut off and generally looks
 unprofessional.
  
   I am creating the colorbars with code like:
cbar1.set_label(Lifetime [$\mu$s], rotation='vertical')

 I don't understand; even with no kwarg, the label on a vertical colorbar
 will be vertical.  It has been that way for as long as I can remember.

 What mpl version are you using?
 Please provide a minimal standalone script showing the problem.

 Eric



  
   And yet the specified rotation has no effect.
  
   Any help would be much appreciated,
   James
  
  
  
  
 
 --
   Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
   user administration capabilities and model configuration. Take
   the hassle out of deploying and managing Subversion and the
   tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
  
  
  
   ___
   Matplotlib-users mailing list
   Matplotlib-users@lists.sourceforge.net
 mailto:Matplotlib-users@lists.sourceforge.net
   https://lists.sourceforge.net/lists/listinfo/matplotlib-users


 
 --
 Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
 user administration capabilities and model configuration. Take
 the hassle out of deploying and managing Subversion and the
 tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 mailto:Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users




 --
 Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
 user administration capabilities and model configuration. Take
 the hassle out of deploying and managing Subversion and the
 tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2



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


--
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar() moves to wrong place on subplots_adjust call

2011-06-16 Thread Jae-Joon Lee
On Tue, Jun 14, 2011 at 4:58 AM, Nicholas Devenish
misnomer+matplot...@gmail.com wrote:
 Is there a way I can avoid or correct this behaviour? It certainly
 seems erroneous that using the figure GUI to adjust plot bounds
 doesn't work, and is an especially nice way of tweaking for final
 plots.


Unfortunately no.
This is a limitation of how colobar is currently implemented (v1.1
will have a workaround to this).
I think the simple (but may not be good enough) workaround is to call
colorbar after subplot adjusting is done.

Alternatively, you may try the axes_grid1 toolkit.

http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html#colorbar-whose-height-or-width-in-sync-with-the-master-axes

Regards,

-JJ

--
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar and scilimits

2011-03-23 Thread Jae-Joon Lee
Unfortunately, ticks in colorbar axes work differently. Use something
like below instead.

cb.formatter.set_scientific(True)
cb.formatter.set_powerlimits((0,4))
cb.update_ticks()


Regards,

-JJ


On Mon, Mar 21, 2011 at 11:26 PM, johanngoetz jgo...@ucla.edu wrote:

 Is there a way to set the style and scilimits to the colorbar axes? All my
 attempts failed. For example, run the following script, I get the error
 shown below:

 ### begin example script
 import numpy
 from matplotlib import pyplot

 n = 500
 x = numpy.random.standard_normal(n)
 y = 2.0 + 3.0 * x + 4.0 * numpy.random.standard_normal(n)
 xmin = x.min()
 xmax = x.max()
 ymin = y.min()
 ymax = y.max()

 hist, edges = numpy.histogramdd([y,x], bins=[25,25],
    range=[[ymin,ymax], [xmin,xmax]])
 extent = [xmin, xmax, ymin, ymax]

 fig = pyplot.figure()
 ax = fig.add_subplot(1,1,1)
 plt = ax.imshow(hist,
    extent = extent,
    origin = 'lower',
    interpolation = 'nearest',
    aspect = 'auto')
 cb = fig.colorbar(plt, ax=ax)

 # This causes an AttributeError exception
 cb.ax.ticklabel_format(style='sci', scilimits=(0,4))

 pyplot.show()
 ### end example script




 python cb_scilim_test.py

 Traceback (most recent call last):
  File cb_scilim_test.py, line 25, in module
    cb.ax.ticklabel_format(style='sci', scilimits=(0,4))
  File /usr/lib64/python2.7/site-packages/matplotlib/axes.py, line 2117,
 in ticklabel_format
    This method only works with the ScalarFormatter.)
 AttributeError: This method only works with the ScalarFormatter.

 --
 View this message in context: 
 http://old.nabble.com/colorbar-and-scilimits-tp31201133p31201133.html
 Sent from the matplotlib - users mailing list archive at Nabble.com.


 --
 Colocation vs. Managed Hosting
 A question and answer guide to determining the best fit
 for your organization - today and in the future.
 http://p.sf.net/sfu/internap-sfd2d
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar+log+latex

2011-01-26 Thread Shrividya Ravi
Hi All,
Thanks a bunch for your help!
Eric: your suggestion works brilliantly ( I didn't use the interpolation
kwarg though because I like the 'smudged' look). Paul: thanks for your
suggestions but I get errors when trying to execute  *
cbar.set_ticks(np.linspace(300,350,6))*. The c.bar.set_ticks option doesn't
seem to exist..

All I now need to figure out is how to get the log scale ticklabels to show
for a different imshow plot...

cheers!
Shrividya
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar+log+latex

2011-01-25 Thread Shrividya Ravi
Hi there,
I too want a log scale on the colorbar for an imshow plot. I have tried the
solution proposed by Jae-Joon but I cannot get the ticklabels to show. I
have tried to dynamically change the matplotlibrc settings in ipython using
mpl.rc('text',usetex=True) - where mpl = matplotlib. When I run the script I
get a whole series of errors (see in italics below) and the figure doesn't
show.
*
RuntimeError: Could not obtain dvipng version
Exception in Tkinter callback
*
Is there another way to get a colorbar with a log scale?

On the same topic of the colorbar, how can I readjust the colors such that
it only goes between user-specified values? For example, I have one imshow
plot where the values range between 0 and 350. However, I only want to look
at the values between 300 and 350.

Any help would be greatly appreciated!

Thanks a lot!
Shrividya
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar+log+latex

2011-01-25 Thread Eric Firing
On 01/25/2011 06:58 PM, Shrividya Ravi wrote:
[...]
 On the same topic of the colorbar, how can I readjust the colors such
 that it only goes between user-specified values? For example, I have one
 imshow plot where the values range between 0 and 350. However, I only
 want to look at the values between 300 and 350.

z = np.arange(25)
z.shape = 5,5
imshow(z, vmin=10, vmax=20, interpolation='nearest')
colorbar(extend='both')

Does that give the desired result?

Eric


 Any help would be greatly appreciated!

 Thanks a lot!
 Shrividya

--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar+log+latex

2011-01-25 Thread Paul Ivanov
Eric Firing, on 2011-01-25 19:52,  wrote:
 On 01/25/2011 06:58 PM, Shrividya Ravi wrote:
 [...]
  On the same topic of the colorbar, how can I readjust the colors such
  that it only goes between user-specified values? For example, I have one
  imshow plot where the values range between 0 and 350. However, I only
  want to look at the values between 300 and 350.
 
 z = np.arange(25)
 z.shape = 5,5
 imshow(z, vmin=10, vmax=20, interpolation='nearest')
 colorbar(extend='both')
 
 Does that give the desired result?

Hi Shrividya,

Here's how I interpreted what was being asked, in case that
helps. 

Also, Eric, is there a reason we make an outline instead of
just cbar.ax.set_frame_on? - My manual adjustments screw up and
confuse whatever data cbar.outline depends on

x = np.random.rand(100)
y = np.random.rand(100)
z = np.random.rand(100)
collection = plt.scatter(x, y, c=z*350, vmin=0, vmax=350)
cbar = plt.colorbar()
cbar.ax.set_ylim(cbar.norm((300,350)))
cbar.ax.set_xlim(cbar.norm((300,350))) # maintain aspect ratio
cbar.set_ticks(np.linspace(300,350,6))
# didn't see a quick way to fix the outline
cbar.outline.set_visible(False) 
cbar.ax.set_frame_on(True)
plt.draw()

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar+log+latex

2011-01-25 Thread Eric Firing
On 01/25/2011 08:51 PM, Paul Ivanov wrote:
 Eric Firing, on 2011-01-25 19:52,  wrote:
 On 01/25/2011 06:58 PM, Shrividya Ravi wrote:
 [...]
 On the same topic of the colorbar, how can I readjust the colors such
 that it only goes between user-specified values? For example, I have one
 imshow plot where the values range between 0 and 350. However, I only
 want to look at the values between 300 and 350.

 z = np.arange(25)
 z.shape = 5,5
 imshow(z, vmin=10, vmax=20, interpolation='nearest')
 colorbar(extend='both')

 Does that give the desired result?

 Hi Shrividya,

 Here's how I interpreted what was being asked, in case that
 helps.

(Your interpretation seems like a very strange thing to want to do, but 
maybe you are right.  The OP can inform us.)


 Also, Eric, is there a reason we make an outline instead of
 just cbar.ax.set_frame_on? - My manual adjustments screw up and
 confuse whatever data cbar.outline depends on

Yes, we need to make our own outline because a colorbar does not have to 
be a rectangle; it can be pointed at either end or both ends.

Eric



 x = np.random.rand(100)
 y = np.random.rand(100)
 z = np.random.rand(100)
 collection = plt.scatter(x, y, c=z*350, vmin=0, vmax=350)
 cbar = plt.colorbar()
 cbar.ax.set_ylim(cbar.norm((300,350)))
 cbar.ax.set_xlim(cbar.norm((300,350))) # maintain aspect ratio
 cbar.set_ticks(np.linspace(300,350,6))
 # didn't see a quick way to fix the outline
 cbar.outline.set_visible(False)
 cbar.ax.set_frame_on(True)
 plt.draw()

 best,


--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar with Axes3D for a set of collections?

2011-01-14 Thread Daniel Mader
Hi Eric,

thanks for your feedback, it helped a lot! I have some questions left,
see below.

2011/1/14 Eric Firing efir...@hawaii.edu:
 Quick thoughts with no testing or concrete examples:

 1) Don't set the cmap or norm for the colorbar; let it inherit those
 properties from the mappable to which it is connected.

Am I doing this correctly in the attached code? It seems there are
several ways of doing this... Which is the suggested one? How can I
label the colorbar?

 2) Ensure that the cmap and norm are the same for all collections.  You
 are already taking care of the cmap, so the problem is that you are
 autoscaling the collections separately, which is setting vmin and vmax
 to different values for the different collections.  Use the data to
 figure out the range (vmin, vmax) that you want the colors to span, and
 then for each collection, instead of col.autoscale(), use

        col.norm.vmin = vmin
        col.norm.vmax = vmax

That was what I needed, see code :)

 (You could also make a single norm instance for all the collections to
 use, just as with the cmap, so that you only have to set vmin and vmax
 once.)

And this I don't understandm could you please elaborate?

Thanks a very lot in advance
best regards from Austria,

Daniel


3D_colorbar.py
Description: Binary data
--
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar with Axes3D for a set of collections?

2011-01-14 Thread Eric Firing

On 01/14/2011 02:02 AM, Daniel Mader wrote:

Hi Eric,

thanks for your feedback, it helped a lot! I have some questions left,
see below.

2011/1/14 Eric Firingefir...@hawaii.edu:

Quick thoughts with no testing or concrete examples:

1) Don't set the cmap or norm for the colorbar; let it inherit those
properties from the mappable to which it is connected.


Am I doing this correctly in the attached code? It seems there are
several ways of doing this... Which is the suggested one? How can I
label the colorbar?


The way you did it is fine. For the label, modify by keeping a reference 
to the colorbar and then calling set_label:


cb = fig.colorbar(collist[-1], shrink=0.85,)#, aspect=5)
cb.set_label('whatever this is')





2) Ensure that the cmap and norm are the same for all collections.  You
are already taking care of the cmap, so the problem is that you are
autoscaling the collections separately, which is setting vmin and vmax
to different values for the different collections.  Use the data to
figure out the range (vmin, vmax) that you want the colors to span, and
then for each collection, instead of col.autoscale(), use

col.norm.vmin = vmin
col.norm.vmax = vmax


That was what I needed, see code :)


(You could also make a single norm instance for all the collections to
use, just as with the cmap, so that you only have to set vmin and vmax
once.)


And this I don't understandm could you please elaborate?


See attached modification.

Eric



Thanks a very lot in advance
best regards from Austria,

Daniel


import sys
import scipy,pylab
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D

##--
def closePolys(elements):
  '''
  close the open polygon elements by adding the first node of each poly again.
  '''
  closed = []
  for nodes in elements:
i = nodes[0]
ii = list(nodes)
ii.append(i)
closed.append(ii)
  return closed

elements = [ [ (0,0), (0,1), (1,1), (1,0) ],
  [ (4,1), (2,3), (2,2), (3,1)],
  [ (0,1), (2,3), (2,2), (1,1)],
  [ (3,0), (3,1), (4,1), (4,0)]]
tmp = scipy.array([1,1.1,0.9,1])
data = [tmp, tmp*2, tmp*4]

## workaround for bug in mpl: close polys manually, no auto-closing!
polys = closePolys(elements)

##--
fig = pylab.figure()
ax = Axes3D(fig)

stacks = 3
zpos = scipy.arange(stacks)

vmin,vmax = scipy.amin(data), scipy.amax(data)
norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)
cmap = mpl.cm.cool

collist = []
for i in range(stacks):
  col = mpl.collections.PolyCollection(polys, linewidths=0.05, closed=False,
norm=norm, cmap=cmap)
  col.set_array(data[i])
  collist.append(col)


for i,col in enumerate(collist):
  ## get number of elements per collection
  elemno = len(col.get_paths())
  ## create *iterable* for the 3D collection slices [z,z,z,...,z]
  zs = [zpos[i]]*elemno
  ## collection transparency (opaque == 1), needed for projection bug workaround
  col.set_alpha(0.3)

  ax.add_collection3d(col, zs=zs, zdir='y')
  #pylab.draw()

## colorbar:

cb = fig.colorbar(collist[-1], shrink=0.85,)#, aspect=5)
cb.set_label('whatever this is')


## axis limit settings:
ax.set_xlim3d(0,4)
ax.set_zlim3d(0,3)
ax.set_ylim3d(-0.1,stacks-1+0.1)

## labels:
ax.set_title('Transparency workaround')
ax.set_xlabel('x')
ax.set_ylabel('slice')
ax.set_zlabel('y')

##--
pylab.show()
--
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar with Axes3D for a set of collections?

2011-01-14 Thread Daniel Mader
Thank you very much for your patience, your explanations helped me a
very lot in getting beautiful plots for my thesis!
Best regards,
Daniel

--
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar with Axes3D for a set of collections?

2011-01-13 Thread Eric Firing
On 01/13/2011 01:40 PM, Daniel Mader wrote:
 Hi,

 I am trying to plot a set of simulation results of FEM simulations.
 With a lot of help from Ben I can plot the deformed shape quite nicely
 but I have trouble in applying a colorbar to the plot.

 In the attached file there are three results with different results.

 How can I apply a global colorbar so that all collections are nicely
 represented?

Quick thoughts with no testing or concrete examples:

1) Don't set the cmap or norm for the colorbar; let it inherit those 
properties from the mappable to which it is connected.

2) Ensure that the cmap and norm are the same for all collections.  You 
are already taking care of the cmap, so the problem is that you are 
autoscaling the collections separately, which is setting vmin and vmax 
to different values for the different collections.  Use the data to 
figure out the range (vmin, vmax) that you want the colors to span, and 
then for each collection, instead of col.autoscale(), use

col.norm.vmin = vmin
col.norm.vmax = vmax

(You could also make a single norm instance for all the collections to 
use, just as with the cmap, so that you only have to set vmin and vmax 
once.)

Eric


 Thanks a lot in advance,
 Daniel



 --
 Protect Your Site and Customers from Malware Attacks
 Learn about various malware tactics and how to avoid them. Understand
 malware threats, the impact they can have on your business, and how you
 can protect your company and customers by using code signing.
 http://p.sf.net/sfu/oracle-sfdevnl



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


--
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar settings with a object oriented approach (or mixed pyplot)

2010-11-21 Thread Jae-Joon Lee
On Thu, Nov 18, 2010 at 11:10 PM, John washa...@gmail.com wrote:
 1) I only need one colorbar, how would I create a single colorbar on
 the right that spanned across all axes? (ie. same height as the stack)

There are a few options you can try. I guess the easiest way is
setting up the axes manually.

dy = 0.8/3.
ax1 = axes([0.1, 0.1, 0.8, dy])
ax2 = axes([0.1, 0.1+dy, 0.8, dy])
ax3 = axes([0.1, 0.1+2*dy, 0.8, dy])

sc = ax1.scatter([1,2],[3,4], c=[0,1], cmap=jet)
cax = axes([0.9, 0.1, 0.03, 0.8])
plt.colorbar(sc, cax=cax)

Also, you make take a look at the axes_grid1 toolkit.
(see e.g, 
http://matplotlib.sourceforge.net/examples/axes_grid/demo_axes_grid.html)

 2) is there a way to place the colorbar in the bottom middle of my
 panels (if I end up with more than one)?

Use loc=8.

 3) How can I customize the tick labels of the colorbar?

You may use set_ticks and set_ticklabels method of the colorbar object.

   cb = plt.colorbar(a.collections[0],cax=ia,orientation='horizontal')
   cb.set_ticks([-100,0,100])
   cb.set_ticklabels([-100, 0, +100])

Also, locators and formatter can be specified during colorbar creation
(take a look at the doc).

-JJ

--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2  L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar uncentered plots

2010-09-29 Thread Benjamin Root
On Tue, Sep 28, 2010 at 10:56 PM, Philip Vetter
pv+matplot...@math.duke.edupv%2bmatplot...@math.duke.edu
 wrote:

 Hello! see below for sample code.

 (1) I find that the second subplot is shifted to the right.
 This seems to happen generally with colorbar. How do I fix it?

 (2) is there a way to clear/remove selected parts of the figure?
 I am using ipython for interactive figure drawing
 I find clf() will erase everything, cla() will empty the square plot,
   but I can't see how to clear the first subfigure or the colorbar.
 This would be useful as any changes to the colorbar create a new one.
 (uncomment the second cbar line to see this)

 (3) is it possible to modify the orientation of cbar once drawn?
 cbar.orientation ='horizontal'
 plt.draw()
 plt.show()
 leaves it unchanged.

 Thank you for your help!

  Here is my code: ==

 #!/usr/bin/env python
 import matplotlib.pyplot as plt
 import numpy as np
 from time import sleep
 x = np.arange(0, 10, 0.2)
 y = np.sin(x)
 fig = plt.figure()
 ax1 = fig.add_subplot(211)
 cax1 = ax1.plot(x, y)
 ax2 = fig.add_subplot(212)
 A = np.random.random_integers(0, 10, 100).reshape(10, 10)
 cax2 = ax2.imshow(A, interpolation=nearest,vmin=-1,vmax=11 )
 cbar = fig.colorbar(cax2)
 #cbar = fig.colorbar(cax2, ticks=[0, 5, 10])
 plt.savefig('colorbartest.pdf')

 ==
 --


Philip,

Typically, when creating a colorbar, matplotlib steals some space from a
particular axes.  This is fine for single plots, but it looks atrocious when
doing subplots.  Instead, what you want is axes_grid1

http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/

(note, if you have a version earlier than 1.0.0, then it is called
axes_grid and it is a little bit different)

With this, you can specify a bunch of layout options ahead of time and get
an object with all of the axes you need.  In particular, I think you want to
look at
http://matplotlib.sourceforge.net/plot_directive/mpl_toolkits/axes_grid/examples/demo_axes_grid.py

A quick note to clear up typical confusion in that demo... You can still use
subplots and embed an AxesGrid within a subplot region (although, I find
this unnecessary).  For this reason, the linked demo has three subplots in a
single figure, and each of those subplots have four subplots.  Therefore,
when creating each AxesGrid, one needs to specify the subplot coordinates
such as 131, 132, 133, but you can simply use 111 if you want AxesGrid to
handle all of your subplotting.

To address one of your other questions, you can easily specify the
orientation of your colorbar to be horizontal or vertical.

I hope that helps!

Ben Root
--
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar questions ...

2010-09-14 Thread Oz Nahum
Hi Ben,
Thanks for your reply it sure helps.
My awkward work around until now was to put before the colorbar:
matplotlib.rc('axes',edgecolor='w')

and the return it to
matplotlib.rc('axes',edgecolor='k').

Does some one knows how to increase the distance between the color bar and
the X-axis ?

Now I noticed that the color bar hides the xlabel 

Thanks again,

Oz


 I agree, Colorbar isn't the most elegant of objects and is probably due for
 some improvements.  I am sure there is probably a better way to do what you
 have done, but I am not familiar with it.  Anyway, to get rid of the box
 around the colorbar, the colorbar object has a member attribute called
 outline which you can set_visible(False).

 a = plt.colorbar()
 a.outline.set_visible(False)

 Should do the trick for that part.

 I hope this helps!
 Ben Root





-- 
Oz Nahum
Graduate Student
Zentrum für Angewandte Geologie
Universität Tübingen

---

Imagine there's no countries
it isn't hard to do
Nothing to kill or die for
And no religion too
Imagine all the people
Living life in peace
--
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar questions ...

2010-09-13 Thread Benjamin Root
On Sat, Sep 11, 2010 at 2:10 PM, Oz Nahum nahu...@gmail.com wrote:

 Hi Everyone again,

 So, with the weekend comes some time to think and I found an answer to
 another question of mine.

 I know now how to remove xticks in colorbar, and I also know how to
 customize the widths of the lines in the color bar.

 import matplotlib
 import numpy as np
 import matplotlib.cm as cm
 import matplotlib.mlab as mlab
 import matplotlib.pyplot as plt
 from pylab import *

 matplotlib.rcParams['xtick.direction'] = 'out'
 matplotlib.rcParams['ytick.direction'] = 'out'

 delta = 0.025
 x = np.arange(-3.0, 3.0, delta)
 y = np.arange(-2.0, 2.0, delta)
 X, Y = np.meshgrid(x, y)
 Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
 Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
 # difference of Gaussians
 Z = 10.0 * (Z2 - Z1)



 # Create a simple contour plot with labels using default colors.  The
 # inline argument to clabel will control whether the labels are draw
 # over the line segments of the contour, removing the lines beneath
 # the label
 plt.figure()
 CS = plt.contour(X, Y, Z)
 plt.clabel(CS, inline=1, fontsize=10,inlinespacing=50)
 a=plt.colorbar()

 ticks = a.ax.get_xticklines()
 lines = a.ax.get_ygridlines()
 children=a.ax.get_children()

 children=a.ax.get_children()

 children[4].set_linewidths([12,12,12,12,12,12])

 for tick in ticks:
 setp(tick, [])


 plt.title('Customize colorbar')


 I hope someone finds that useful. And someone is still following my
 monologue, my question, how to remove the axes around the colorbar, or at
 least changed the to be non-visible, still stands...

 Thanks,

 Oz


Oz,

I agree, Colorbar isn't the most elegant of objects and is probably due for
some improvements.  I am sure there is probably a better way to do what you
have done, but I am not familiar with it.  Anyway, to get rid of the box
around the colorbar, the colorbar object has a member attribute called
outline which you can set_visible(False).

a = plt.colorbar()
a.outline.set_visible(False)

Should do the trick for that part.

I hope this helps!
Ben Root
--
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar questions ...

2010-09-13 Thread Alan G Isaac
On 9/11/2010 3:10 PM, Oz Nahum wrote:
 my question, how to remove the axes around the colorbar, or at least changed 
 the to be non-visible, still stands...

Did you resolve this?

Alan Isaac


--
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar questions ...

2010-09-11 Thread Oz Nahum
Hi Everyone again,

So, with the weekend comes some time to think and I found an answer to
another question of mine.

I know now how to remove xticks in colorbar, and I also know how to
customize the widths of the lines in the color bar.

import matplotlib
import numpy as np
import matplotlib.cm as cm
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
from pylab import *

matplotlib.rcParams['xtick.direction'] = 'out'
matplotlib.rcParams['ytick.direction'] = 'out'

delta = 0.025
x = np.arange(-3.0, 3.0, delta)
y = np.arange(-2.0, 2.0, delta)
X, Y = np.meshgrid(x, y)
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
# difference of Gaussians
Z = 10.0 * (Z2 - Z1)



# Create a simple contour plot with labels using default colors.  The
# inline argument to clabel will control whether the labels are draw
# over the line segments of the contour, removing the lines beneath
# the label
plt.figure()
CS = plt.contour(X, Y, Z)
plt.clabel(CS, inline=1, fontsize=10,inlinespacing=50)
a=plt.colorbar()
ticks = a.ax.get_xticklines()
lines = a.ax.get_ygridlines()
children=a.ax.get_children()

children=a.ax.get_children()

children[4].set_linewidths([12,12,12,12,12,12])

for tick in ticks:
setp(tick, [])


plt.title('Customize colorbar')


I hope someone finds that useful. And someone is still following my
monologue, my question, how to remove the axes around the colorbar, or at
least changed the to be non-visible, still stands...

Thanks,

Oz


-- 
Oz Nahum
Graduate Student
Zentrum für Angewandte Geologie
Universität Tübingen

---

Imagine there's no countries
it isn't hard to do
Nothing to kill or die for
And no religion too
Imagine all the people
Living life in peace
--
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar labeling

2010-08-23 Thread Friedrich Romstedt
2010/8/20 Bruce Ford br...@clearscienceinc.com:
 I have a grid with values ranging from exactly 0.0 and 100.0.  When I
 plot this with colorbar, the base of the colorbar is labeled -0.0.
 Is this a default for 0.0...to plot it with as a negative number?  Any
 workarounds?

How sure are you that the floating point number underneath has really
not set the negative bit?

Maybe try to .clip() the grid positions before on the numpy level to
(0.0, \infty) where 0 arises from a fresh parse of '0.0' by the
interpreter, i.e., a really really zero fp number.

To clip, you may also use

grid *= (grid  0)

or similar things of that fashion.

I'm not sure if the mistake is implied my your side of the code, but i
just hope this helps maybe.  The Locator stuff is not soo easy.

Friedrich

--
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar labeling

2010-08-20 Thread Eric Firing
On 08/20/2010 05:29 AM, Bruce Ford wrote:
 I have a grid with values ranging from exactly 0.0 and 100.0.  When I
 plot this with colorbar, the base of the colorbar is labeled -0.0.
 Is this a default for 0.0...to plot it with as a negative number?  Any
 workarounds?

Would you provide a minimal runnable example, please, and specify what 
mpl version you are using?  It is certainly not intended or usual that 0 
be displayed as -0.

Eric



 Bruce

 ---
 Bruce W. Ford
 Clear Science, Inc.

--
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar labeling

2010-08-20 Thread Bruce Ford
This effect is happening within an web app that displays gridded
fields from multiple datasets (~4500 lines of code).  So I it's tricky
to create an example.  Although if I use numpy.min(grid) the minimum
is 0.  So, I think colorbar or matplotlib is interpreting the 0 as -0.
 (Matplotlib version 0.99.0 RC0)

The colorbar call that I'm using is:

cbar = pyplot.colorbar(plot,shrink=0.7, format=%1.1f,
spacing='proportional',orientation='vertical')

cbar.ax.set_ylabel(cbar_label(param,unit))

The function cbar_label is:

def cbar_label(param,unit):
#Helper function for making colorbar label
if param == sig:
if unit==1:
cbar_label = Feet
else:
cbar_label = Meters
elif param == dir:
cbar_label = Radial Direction
elif param == per:
cbar_label = Seconds
elif param[-5:] == _wind:
if unit == 3:
cbar_label = Kts
else:
cbar_label = M/S
elif param[-4:] == _hgt:
if unit == 5:
cbar_label = GPFt
else:
cbar_label = GPM
elif param == slp:
cbar_label = Millibars
elif param == 1000_rh:
cbar_label = %
elif param == 1000_temp:
if unit == 9:
cbar_label = Degrees F
else:
cbar_label = Degrees C
else:
cbar_label = param
return cbar_label

If this doesn't offer anything, I'll try to generate a
compartmentalized example of the issue.

Bruce
---
Bruce W. Ford
Clear Science, Inc.
br...@clearscienceinc.com
http://www.ClearScienceInc.com
http://www.facebook.com/clearscience
http://www.twitter.com/ROVs_rule
Phone: (904) 796-8101
Fax:  (904) 379-9704
8241 Parkridge Circle N.
Jacksonville, FL  32211
Skype:  bruce.w.ford

---
To schedule a meeting with Bruce, Go to: http://tungle.me/bruceford





On Fri, Aug 20, 2010 at 2:06 PM, Eric Firing efir...@hawaii.edu wrote:
 On 08/20/2010 05:29 AM, Bruce Ford wrote:
 I have a grid with values ranging from exactly 0.0 and 100.0.  When I
 plot this with colorbar, the base of the colorbar is labeled -0.0.
 Is this a default for 0.0...to plot it with as a negative number?  Any
 workarounds?

 Would you provide a minimal runnable example, please, and specify what
 mpl version you are using?  It is certainly not intended or usual that 0
 be displayed as -0.

 Eric



 Bruce

 ---
 Bruce W. Ford
 Clear Science, Inc.

 --
 This SF.net email is sponsored by

 Make an app they can't live without
 Enter the BlackBerry Developer Challenge
 http://p.sf.net/sfu/RIM-dev2dev
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar labeling

2010-08-20 Thread Eric Firing
On 08/20/2010 10:14 AM, Bruce Ford wrote:
 This effect is happening within an web app that displays gridded
 fields from multiple datasets (~4500 lines of code).  So I it's tricky
 to create an example.  Although if I use numpy.min(grid) the minimum
 is 0.  So, I think colorbar or matplotlib is interpreting the 0 as -0.


You are talking about the colorbar tick labels, correct?  The lowest 
tick label is coming out as -0.0?


   (Matplotlib version 0.99.0 RC0)

 The colorbar call that I'm using is:

 cbar = pyplot.colorbar(plot,shrink=0.7, format=%1.1f,
 spacing='proportional',orientation='vertical')

This means your colorbar tick values are simply being formatted by 
python, like this:

In [1]: %1.1f % -0.001
Out[1]: '-0.0'

In [2]: %1.1f % 0.001
Out[2]: '0.0'

In [3]: %1.1f % 0.0
Out[3]: '0.0'

In [4]: %1.1f % -0.0
Out[4]: '-0.0'

In [5]: import numpy

In [6]: numpy.min(-0.0)
Out[6]: -0

In [7]: -0.0 == 0.0
Out[7]: True


So I suspect the problem is that a small negative value, or a negative 
zero, is becoming the tick value.  I don't know why.  You may or may not 
want to investigate.

I dimly recall a problem like this cropping up on the list before--but I 
don't remember anything else about it.

Here is a workaround (untested, but should be close):

from matplotlib.ticker import FormatStrFormatter
class MyCBFormatter(FormatStrFormatter):
 def __call__(self, x, pos=None):
 xstr = self.fmt % x
 if float(xstr) == 0:
 return self.fmt % 0
 return xstr
cbar = pyplot.colorbar(plot,shrink=0.7, format=MyCBFormatter(%1.1f),
  spacing='proportional',orientation='vertical')


Eric


 cbar.ax.set_ylabel(cbar_label(param,unit))

 The function cbar_label is:

 def cbar_label(param,unit):
  #Helper function for making colorbar label
  if param == sig:
  if unit==1:
  cbar_label = Feet
  else:
  cbar_label = Meters
  elif param == dir:
  cbar_label = Radial Direction
  elif param == per:
  cbar_label = Seconds
  elif param[-5:] == _wind:
  if unit == 3:
  cbar_label = Kts
  else:
  cbar_label = M/S
  elif param[-4:] == _hgt:
  if unit == 5:
  cbar_label = GPFt
  else:
  cbar_label = GPM
  elif param == slp:
  cbar_label = Millibars
  elif param == 1000_rh:
  cbar_label = %
  elif param == 1000_temp:
  if unit == 9:
  cbar_label = Degrees F
  else:
  cbar_label = Degrees C
  else:
  cbar_label = param
  return cbar_label

 If this doesn't offer anything, I'll try to generate a
 compartmentalized example of the issue.

 Bruce

--
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar labeling

2010-08-20 Thread Bruce Ford
Thanks I'll give this a try.  numpy.min(grid) reports 0.0 (no
negative) yet it labels as -0.0, BTW, but let me give this a try.

Bruce

---
Bruce W. Ford
Clear Science, Inc.
br...@clearscienceinc.com
http://www.ClearScienceInc.com
http://www.facebook.com/clearscience
http://www.twitter.com/ROVs_rule
Phone: (904) 796-8101
Fax:  (904) 379-9704
8241 Parkridge Circle N.
Jacksonville, FL  32211
Skype:  bruce.w.ford

---
To schedule a meeting with Bruce, Go to: http://tungle.me/bruceford





On Fri, Aug 20, 2010 at 4:44 PM, Eric Firing efir...@hawaii.edu wrote:
 On 08/20/2010 10:14 AM, Bruce Ford wrote:
 This effect is happening within an web app that displays gridded
 fields from multiple datasets (~4500 lines of code).  So I it's tricky
 to create an example.  Although if I use numpy.min(grid) the minimum
 is 0.  So, I think colorbar or matplotlib is interpreting the 0 as -0.


 You are talking about the colorbar tick labels, correct?  The lowest
 tick label is coming out as -0.0?


   (Matplotlib version 0.99.0 RC0)

 The colorbar call that I'm using is:

 cbar = pyplot.colorbar(plot,shrink=0.7, format=%1.1f,
 spacing='proportional',orientation='vertical')

 This means your colorbar tick values are simply being formatted by
 python, like this:

 In [1]: %1.1f % -0.001
 Out[1]: '-0.0'

 In [2]: %1.1f % 0.001
 Out[2]: '0.0'

 In [3]: %1.1f % 0.0
 Out[3]: '0.0'

 In [4]: %1.1f % -0.0
 Out[4]: '-0.0'

 In [5]: import numpy

 In [6]: numpy.min(-0.0)
 Out[6]: -0

 In [7]: -0.0 == 0.0
 Out[7]: True


 So I suspect the problem is that a small negative value, or a negative
 zero, is becoming the tick value.  I don't know why.  You may or may not
 want to investigate.

 I dimly recall a problem like this cropping up on the list before--but I
 don't remember anything else about it.

 Here is a workaround (untested, but should be close):

 from matplotlib.ticker import FormatStrFormatter
 class MyCBFormatter(FormatStrFormatter):
     def __call__(self, x, pos=None):
         xstr = self.fmt % x
         if float(xstr) == 0:
             return self.fmt % 0
         return xstr
 cbar = pyplot.colorbar(plot,shrink=0.7, format=MyCBFormatter(%1.1f),
          spacing='proportional',orientation='vertical')


 Eric


 cbar.ax.set_ylabel(cbar_label(param,unit))

 The function cbar_label is:

 def cbar_label(param,unit):
      #Helper function for making colorbar label
      if param == sig:
          if unit==1:
              cbar_label = Feet
          else:
              cbar_label = Meters
      elif param == dir:
          cbar_label = Radial Direction
      elif param == per:
          cbar_label = Seconds
      elif param[-5:] == _wind:
          if unit == 3:
              cbar_label = Kts
          else:
              cbar_label = M/S
      elif param[-4:] == _hgt:
          if unit == 5:
              cbar_label = GPFt
          else:
              cbar_label = GPM
      elif param == slp:
          cbar_label = Millibars
      elif param == 1000_rh:
          cbar_label = %
      elif param == 1000_temp:
          if unit == 9:
              cbar_label = Degrees F
          else:
              cbar_label = Degrees C
      else:
          cbar_label = param
      return cbar_label

 If this doesn't offer anything, I'll try to generate a
 compartmentalized example of the issue.

 Bruce

 --
 This SF.net email is sponsored by

 Make an app they can't live without
 Enter the BlackBerry Developer Challenge
 http://p.sf.net/sfu/RIM-dev2dev
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar labeling

2010-08-20 Thread Eric Firing
On 08/20/2010 10:51 AM, Bruce Ford wrote:
 Thanks I'll give this a try.  numpy.min(grid) reports 0.0 (no
 negative) yet it labels as -0.0, BTW, but let me give this a try.

Bruce,

What matters is not min(grid), but the value of the tick. Unless you are 
forcing them to be the same via a kwarg (which I don't see), they may 
differ, as seems to be the case.  Unfortunately, this is hard to debug, 
because there is no way to get at the set of numbers that are being 
formatted to give the tick labels.  Doing something like this:

print cbar.cax.get_yticks()

will be of no help, because the tick positions are on a 0-1 scale 
regardless of the values they represent.

You can, however, specify the desired tick values as a sequence via the 
ticks kwarg to colorbar.  Ticks in that sequence but outside the actual 
colorbar range (as set by the clim() function, for example) will not appear.

Eric


 Bruce

 ---
 Bruce W. Ford
 Clear Science, Inc.
 br...@clearscienceinc.com
 http://www.ClearScienceInc.com
 http://www.facebook.com/clearscience
 http://www.twitter.com/ROVs_rule
 Phone: (904) 796-8101
 Fax:  (904) 379-9704
 8241 Parkridge Circle N.
 Jacksonville, FL  32211
 Skype:  bruce.w.ford

 ---
 To schedule a meeting with Bruce, Go to: http://tungle.me/bruceford
 




 On Fri, Aug 20, 2010 at 4:44 PM, Eric Firingefir...@hawaii.edu  wrote:
 On 08/20/2010 10:14 AM, Bruce Ford wrote:
 This effect is happening within an web app that displays gridded
 fields from multiple datasets (~4500 lines of code).  So I it's tricky
 to create an example.  Although if I use numpy.min(grid) the minimum
 is 0.  So, I think colorbar or matplotlib is interpreting the 0 as -0.


 You are talking about the colorbar tick labels, correct?  The lowest
 tick label is coming out as -0.0?


(Matplotlib version 0.99.0 RC0)

 The colorbar call that I'm using is:

 cbar = pyplot.colorbar(plot,shrink=0.7, format=%1.1f,
 spacing='proportional',orientation='vertical')

 This means your colorbar tick values are simply being formatted by
 python, like this:

 In [1]: %1.1f % -0.001
 Out[1]: '-0.0'

 In [2]: %1.1f % 0.001
 Out[2]: '0.0'

 In [3]: %1.1f % 0.0
 Out[3]: '0.0'

 In [4]: %1.1f % -0.0
 Out[4]: '-0.0'

 In [5]: import numpy

 In [6]: numpy.min(-0.0)
 Out[6]: -0

 In [7]: -0.0 == 0.0
 Out[7]: True


 So I suspect the problem is that a small negative value, or a negative
 zero, is becoming the tick value.  I don't know why.  You may or may not
 want to investigate.

 I dimly recall a problem like this cropping up on the list before--but I
 don't remember anything else about it.

 Here is a workaround (untested, but should be close):

 from matplotlib.ticker import FormatStrFormatter
 class MyCBFormatter(FormatStrFormatter):
  def __call__(self, x, pos=None):
  xstr = self.fmt % x
  if float(xstr) == 0:
  return self.fmt % 0
  return xstr
 cbar = pyplot.colorbar(plot,shrink=0.7, format=MyCBFormatter(%1.1f),
   spacing='proportional',orientation='vertical')


 Eric


 cbar.ax.set_ylabel(cbar_label(param,unit))

 The function cbar_label is:

 def cbar_label(param,unit):
   #Helper function for making colorbar label
   if param == sig:
   if unit==1:
   cbar_label = Feet
   else:
   cbar_label = Meters
   elif param == dir:
   cbar_label = Radial Direction
   elif param == per:
   cbar_label = Seconds
   elif param[-5:] == _wind:
   if unit == 3:
   cbar_label = Kts
   else:
   cbar_label = M/S
   elif param[-4:] == _hgt:
   if unit == 5:
   cbar_label = GPFt
   else:
   cbar_label = GPM
   elif param == slp:
   cbar_label = Millibars
   elif param == 1000_rh:
   cbar_label = %
   elif param == 1000_temp:
   if unit == 9:
   cbar_label = Degrees F
   else:
   cbar_label = Degrees C
   else:
   cbar_label = param
   return cbar_label

 If this doesn't offer anything, I'll try to generate a
 compartmentalized example of the issue.

 Bruce

 --
 This SF.net email is sponsored by

 Make an app they can't live without
 Enter the BlackBerry Developer Challenge
 http://p.sf.net/sfu/RIM-dev2dev
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


 --
 This SF.net email is sponsored by

 Make an app they can't live without
 Enter the BlackBerry Developer Challenge
 http://p.sf.net/sfu/RIM-dev2dev
 ___
 Matplotlib-users mailing 

Re: [Matplotlib-users] colorbar rescaling

2010-06-29 Thread Alexander Dietz
Hi Friedrich,

thanks a lot, that was exactly what I was looking for...


Alex

On Mon, Jun 28, 2010 at 23:00, Friedrich Romstedt 
friedrichromst...@gmail.com wrote:

 2010/6/28 Alexander Dietz alexanderdie...@googlemail.com:
  I have a plot, to which I am drawing a colorbar. The standard colorbar
  ranges from the values -1 (blue) over 0 (green) to e.g. 1(red). So far so
  good.
  But now I want to change the colorbar that it shows only the colors
 between
  0 and 1. What I mean is: the colorbar should start at value 0 (with
 green)
  and go to 1(red), and leave the original plot unchanged.

 Ah, it wasn't that easy (for me).

 Friedrich

--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar rescaling

2010-06-28 Thread Friedrich Romstedt
2010/6/28 Alexander Dietz alexanderdie...@googlemail.com:
 I have a plot, to which I am drawing a colorbar. The standard colorbar
 ranges from the values -1 (blue) over 0 (green) to e.g. 1(red). So far so
 good.
 But now I want to change the colorbar that it shows only the colors between
 0 and 1. What I mean is: the colorbar should start at value 0 (with green)
 and go to 1(red), and leave the original plot unchanged.

Ah, it wasn't that easy (for me).

Friedrich


help.py
Description: Binary data
--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar and logscale

2010-06-24 Thread Benjamin Root
Benoit,

Is there any particular reason why you can't do a log10() of the data that
is being pcolor()'d and then label the colorbar as having units of dB?  That
would seem to be the most straight-forward approach to me.

Ben Root


2010/6/24 Benoit Donnet benoit.don...@uclouvain.be

 Hi guys,

 I'm struggling with colorbar since this morning.  I'd like the colorbar
 being logscale

 I'm experimenting some strange behavior with the colorbar as some 'labels'
 appear several times.  For instance, 10^0 appears three times, 10^1 appears
 also three times, and so on.  I believe the exponent is the digit of the
 float, while I'd like to see the exponent (of the scientific notation)

 I attach a png of the plot

 Here is my code:

 k,m,fp = np.loadtxt(file, unpack=True)
 ki = linspace(k.min(), k.max(), 37)
 mi = linspace(m.min(), m.max(), 37)
 Z = griddata(k, m, fp, ki, mi)
 Z.shape
 K, M = meshgrid(ki, mi)

 pcolor(K, M, log10(Z))#, cmap=cm.gray)
 cbar = colorbar(format=FormatStrFormatter('$10^{%d}$'))

 semilogy()
 axis([1,20,1,50], font2)
 xlabel(r'\textrm{\# hash functions ($k$)}', font)
 ylabel(r'\textrm{vector size ($m$)}', font)
 cbar.ax.set_ylabel(r'$f_p$', font)

 I obviously suspect my code is flawed somewhere but I can't figure out
 where.  i have tested several format for the colorbar, like
 LogFormatterMathText, but it does not solve my problem.

 I would appreciate any kind of help.  Thanks in advance

 Keep on Rockin'

 Benoit




 ---
 Dr. Benoit Donnet
 Université catholique de Louvain (UCL)
 Ecole Polytechnique de Louvain (EPL) - Département d'Ingénierie
 Informatique (INGI)
 Place Sainte Barbe, 2
 B-1348 Louvain-la-Neuve
 Phone: +32 10 47 87 18
 Fax: +32 10 45 03 45







 --
 ThinkGeek and WIRED's GeekDad team up for the Ultimate
 GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
 lucky parental unit.  See the prize list and enter to win:
 http://p.sf.net/sfu/thinkgeek-promo
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar and logscale

2010-06-24 Thread Benoit Donnet
Hello Benjamin,

Thanks for your reply.

 Is there any particular reason why you can't do a log10() of the data that is 
 being pcolor()'d and then label the colorbar as having units of dB?  That 
 would seem to be the most straight-forward approach to me.

That's what I first tested.

In that case, labels on the colorbar are the following (i don't attach the plot 
to avoid spamming the entire mailing-list): 0.0, -0.4, -0.8, -1.2, -1.6, ..., 
-3.6).  It does not mean anything :s

Benoit 

 
 Ben Root
 
 
 2010/6/24 Benoit Donnet benoit.don...@uclouvain.be
 Hi guys,
 
 I'm struggling with colorbar since this morning.  I'd like the colorbar being 
 logscale
 
 I'm experimenting some strange behavior with the colorbar as some 'labels' 
 appear several times.  For instance, 10^0 appears three times, 10^1 appears 
 also three times, and so on.  I believe the exponent is the digit of the 
 float, while I'd like to see the exponent (of the scientific notation)
 
 I attach a png of the plot
 
 Here is my code:
 
 k,m,fp = np.loadtxt(file, unpack=True)
 ki = linspace(k.min(), k.max(), 37)
 mi = linspace(m.min(), m.max(), 37)
 Z = griddata(k, m, fp, ki, mi)
 Z.shape
 K, M = meshgrid(ki, mi)
 
 pcolor(K, M, log10(Z))#, cmap=cm.gray)
 cbar = colorbar(format=FormatStrFormatter('$10^{%d}$'))
 
 semilogy()
 axis([1,20,1,50], font2)
 xlabel(r'\textrm{\# hash functions ($k$)}', font)
 ylabel(r'\textrm{vector size ($m$)}', font)
 cbar.ax.set_ylabel(r'$f_p$', font)
 
 I obviously suspect my code is flawed somewhere but I can't figure out where. 
  i have tested several format for the colorbar, like LogFormatterMathText, 
 but it does not solve my problem.
 
 I would appreciate any kind of help.  Thanks in advance
 
 Keep on Rockin'
 
 Benoit
 
 
 
 
 ---
 Dr. Benoit Donnet
 Université catholique de Louvain (UCL)
 Ecole Polytechnique de Louvain (EPL) - Département d'Ingénierie Informatique 
 (INGI)
 Place Sainte Barbe, 2
 B-1348 Louvain-la-Neuve
 Phone: +32 10 47 87 18
 Fax: +32 10 45 03 45
 
 
 
 
 
 
 --
 ThinkGeek and WIRED's GeekDad team up for the Ultimate
 GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
 lucky parental unit.  See the prize list and enter to win:
 http://p.sf.net/sfu/thinkgeek-promo
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 
 

---
Dr. Benoit Donnet
Université catholique de Louvain (UCL)
Ecole Polytechnique de Louvain (EPL) - Département d'Ingénierie Informatique 
(INGI)
Place Sainte Barbe, 2
B-1348 Louvain-la-Neuve
Phone: +32 10 47 87 18
Fax: +32 10 45 03 45





--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar and logscale

2010-06-24 Thread Benjamin Root
Ah, I just noticed that.

Actually, I think I just figured out what is happening.  The colorbar
automatically chooses what values to display, and in your case, the values
are 0.0, -0.4, -0.8, -1.2, -1.6, ..., -3.6, which when turned into integers
are 0, 0, 0, -1, -1, ..., -3, which matches what your first plot had.  All
we have to do is specify the values that the colorbar should list.  I am not
very familiar with this aspect, but it has something to do with specifying
your colormap and/or the normalizer.

Does anybody know of a good tutorial on creating colormaps and normalizers?

Ben Root


On Thu, Jun 24, 2010 at 8:53 AM, Benoit Donnet
benoit.don...@uclouvain.bewrote:

 Hello Benjamin,

 Thanks for your reply.

 Is there any particular reason why you can't do a log10() of the data that
 is being pcolor()'d and then label the colorbar as having units of dB?  That
 would seem to be the most straight-forward approach to me.


 That's what I first tested.

 In that case, labels on the colorbar are the following (i don't attach the
 plot to avoid spamming the entire mailing-list): 0.0, -0.4, -0.8, -1.2,
 -1.6, ..., -3.6).  It does not mean anything :s

 Benoit


 Ben Root


 2010/6/24 Benoit Donnet benoit.don...@uclouvain.be

 Hi guys,

 I'm struggling with colorbar since this morning.  I'd like the colorbar
 being logscale

 I'm experimenting some strange behavior with the colorbar as some 'labels'
 appear several times.  For instance, 10^0 appears three times, 10^1 appears
 also three times, and so on.  I believe the exponent is the digit of the
 float, while I'd like to see the exponent (of the scientific notation)

 I attach a png of the plot

 Here is my code:

 k,m,fp = np.loadtxt(file, unpack=True)
 ki = linspace(k.min(), k.max(), 37)
 mi = linspace(m.min(), m.max(), 37)
 Z = griddata(k, m, fp, ki, mi)
 Z.shape
 K, M = meshgrid(ki, mi)

 pcolor(K, M, log10(Z))#, cmap=cm.gray)
 cbar = colorbar(format=FormatStrFormatter('$10^{%d}$'))

 semilogy()
 axis([1,20,1,50], font2)
 xlabel(r'\textrm{\# hash functions ($k$)}', font)
 ylabel(r'\textrm{vector size ($m$)}', font)
 cbar.ax.set_ylabel(r'$f_p$', font)

 I obviously suspect my code is flawed somewhere but I can't figure out
 where.  i have tested several format for the colorbar, like
 LogFormatterMathText, but it does not solve my problem.

 I would appreciate any kind of help.  Thanks in advance

 Keep on Rockin'

 Benoit




 ---
 Dr. Benoit Donnet
 Université catholique de Louvain (UCL)
 Ecole Polytechnique de Louvain (EPL) - Département d'Ingénierie
 Informatique (INGI)
 Place Sainte Barbe, 2
 B-1348 Louvain-la-Neuve
 Phone: +32 10 47 87 18
 Fax: +32 10 45 03 45







 --
 ThinkGeek and WIRED's GeekDad team up for the Ultimate
 GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
 lucky parental unit.  See the prize list and enter to win:
 http://p.sf.net/sfu/thinkgeek-promo
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users



  ---
 Dr. Benoit Donnet
 Université catholique de Louvain (UCL)
 Ecole Polytechnique de Louvain (EPL) - Département d'Ingénierie
 Informatique (INGI)
 Place Sainte Barbe, 2
 B-1348 Louvain-la-Neuve
 Phone: +32 10 47 87 18
 Fax: +32 10 45 03 45






--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar and logscale

2010-06-24 Thread Eric Firing
On 06/24/2010 04:03 AM, Benjamin Root wrote:
 Ah, I just noticed that.

 Actually, I think I just figured out what is happening.  The colorbar
 automatically chooses what values to display, and in your case, the
 values are 0.0, -0.4, -0.8, -1.2, -1.6, ..., -3.6, which when turned
 into integers are 0, 0, 0, -1, -1, ..., -3, which matches what your

Right, good eye!

 first plot had.  All we have to do is specify the values that the
 colorbar should list.  I am not very familiar with this aspect, but it
 has something to do with specifying your colormap and/or the normalizer.

The tick locations can be specified via the ticks kwarg to colorbar. 
 From the docstring:

 *ticks*   [ None | list of ticks | Locator object ]
   If None, ticks are determined automatically from the
   input.
 *format*  [ None | format string | Formatter object ]
   If None, the
   :class:`~matplotlib.ticker.ScalarFormatter` is used.
   If a format string is given, e.g. '%.3f', that is
   used. An alternative
   :class:`~matplotlib.ticker.Formatter` object may be
   given instead.

The OP may also wish to specify the range of the colormap via the vmin 
and vmax kwargs to pcolor (note that everything to do with the colormap 
and the norm is specified in pcolor, not in the call to colorbar.

The OP probably does not need to specify both the formatter and the 
ticker.  If it is certain that the range of values will be substantially 
geater than one, and integer tick values are desired, then try this:

int_ticker = MaxNLocator(nbins=6, integer=True)
cbar = colorbar(ticks=int_ticker)

nbins is the maximum number of intervals (one less than the max number 
of ticks).

The default formatter will print integers as integers, so no custom 
formatter is needed.  Specifying a custom format or formatter is risky 
because, as illustrated by your diagnosis of the OP's original problem, 
it can easily lead to labels that are not accurate representations of 
the tick values.



 Does anybody know of a good tutorial on creating colormaps and normalizers?

Custom norms are rare, and I don't think there is much in the way of 
documentation or examples.  The code in ticker.py is probably the best 
starting place for learning about customizing norms; it includes 
subclasses of Normalize. Colormaps are illustrated fairly well in the 
examples.  See the second example in 
http://matplotlib.sourceforge.net/examples/pylab_examples/contourf_demo.html 
for ListedColormap, see 
http://matplotlib.sourceforge.net/examples/pylab_examples/contourf_demo.html 
for examples of how to use the somewhat complicated 
LinearSegmentedColormap to generate a custom map, and 
http://matplotlib.sourceforge.net/examples/pylab_examples/show_colormaps.html 
for a view of built-in colormaps.

Eric


 Ben Root


 On Thu, Jun 24, 2010 at 8:53 AM, Benoit Donnet
 benoit.don...@uclouvain.be mailto:benoit.don...@uclouvain.be wrote:

 Hello Benjamin,

 Thanks for your reply.

 Is there any particular reason why you can't do a log10() of the
 data that is being pcolor()'d and then label the colorbar as
 having units of dB?  That would seem to be the most
 straight-forward approach to me.

 That's what I first tested.

 In that case, labels on the colorbar are the following (i don't
 attach the plot to avoid spamming the entire mailing-list): 0.0,
 -0.4, -0.8, -1.2, -1.6, ..., -3.6).  It does not mean anything :s

 Benoit


 Ben Root


 2010/6/24 Benoit Donnet benoit.don...@uclouvain.be
 mailto:benoit.don...@uclouvain.be

 Hi guys,

 I'm struggling with colorbar since this morning.  I'd like the
 colorbar being logscale

 I'm experimenting some strange behavior with the colorbar as
 some 'labels' appear several times.  For instance, 10^0
 appears three times, 10^1 appears also three times, and so on.
  I believe the exponent is the digit of the float, while I'd
 like to see the exponent (of the scientific notation)

 I attach a png of the plot

 Here is my code:

 k,m,fp = np.loadtxt(file, unpack=True)
 ki = linspace(k.min(), k.max(), 37)
 mi = linspace(m.min(), m.max(), 37)
 Z = griddata(k, m, fp, ki, mi)
 Z.shape
 K, M = meshgrid(ki, mi)

 pcolor(K, M, log10(Z))#, cmap=cm.gray)
 cbar = colorbar(format=FormatStrFormatter('$10^{%d}$'))

 semilogy()
 axis([1,20,1,50], font2)
 xlabel(r'\textrm{\# hash functions ($k$)}', font)
 ylabel(r'\textrm{vector size ($m$)}', font)
 cbar.ax.set_ylabel(r'$f_p$', font)

 I obviously suspect my code is flawed somewhere but I can't
 figure out where.  i have tested several format for the
 colorbar, like 

Re: [Matplotlib-users] colorbar+log+latex

2010-04-20 Thread Yves Revaz
Ok, great, it works !

However, I do not understand why latex mode is
disabled by default...

Anyway, thanks a lot,

yves


Jae-Joon Lee wrote:
 I'm not sure if the default formatter needs to be changed.
 However, you may try

 import matplotlib.ticker as ticker
 formatter=ticker.LogFormatterMathtext()
 colorbar(format=formatter)

 which will render colorbar ticklabels with mathtext mode.

 Regards,

 -JJ


 On Fri, Apr 16, 2010 at 3:56 AM, Yves Revaz yves.re...@epfl.ch wrote:
   
 Dear list,

 I want to plot colored points using scatter, with the
 color of points corresponding to the log of the z value of the points.

 the corresponding scatter command is :

 scatter(x,y,c=z,norm=colors.LogNorm())

 unfortunately, then I then draw a colorbar simply calling

 colorbar()

 the fonts used for the color bar is no longer in latex mode,
 as it was if I use a lin scale in scatter(), i.e., norm=None.


 Is it a bug ?

 Any solution ?

 Thanks,

 yves




 --
 (o o)
 oOO--(_)--OOo---
  Dr. Yves Revaz
  Laboratory of Astrophysics EPFL
  Observatoire de Sauverny Tel : ++ 41 22 379 24 28
  51. Ch. des Maillettes   Fax : ++ 41 22 379 22 05
  1290 Sauverny e-mail : yves.re...@epfl.ch
  SWITZERLAND  Web : http://www.lunix.ch/revaz/
 


 --
 Download Intel#174; Parallel Studio Eval
 Try the new software tools for yourself. Speed compiling, find bugs
 proactively, and fine-tune applications for parallel performance.
 See why Intel Parallel Studio got high marks during beta.
 http://p.sf.net/sfu/intel-sw-dev
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users

 


-- 
 (o o)
oOO--(_)--OOo---
  Dr. Yves Revaz
  Laboratory of Astrophysics EPFL
  Observatoire de Sauverny Tel : ++ 41 22 379 24 28
  51. Ch. des Maillettes   Fax : ++ 41 22 379 22 05
  1290 Sauverny e-mail : yves.re...@epfl.ch
  SWITZERLAND  Web : http://www.lunix.ch/revaz/



--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar+log+latex

2010-04-19 Thread Jae-Joon Lee
I'm not sure if the default formatter needs to be changed.
However, you may try

import matplotlib.ticker as ticker
formatter=ticker.LogFormatterMathtext()
colorbar(format=formatter)

which will render colorbar ticklabels with mathtext mode.

Regards,

-JJ


On Fri, Apr 16, 2010 at 3:56 AM, Yves Revaz yves.re...@epfl.ch wrote:
 Dear list,

 I want to plot colored points using scatter, with the
 color of points corresponding to the log of the z value of the points.

 the corresponding scatter command is :

 scatter(x,y,c=z,norm=colors.LogNorm())

 unfortunately, then I then draw a colorbar simply calling

 colorbar()

 the fonts used for the color bar is no longer in latex mode,
 as it was if I use a lin scale in scatter(), i.e., norm=None.


 Is it a bug ?

 Any solution ?

 Thanks,

 yves




 --
                                                 (o o)
 oOO--(_)--OOo---
  Dr. Yves Revaz
  Laboratory of Astrophysics EPFL
  Observatoire de Sauverny     Tel : ++ 41 22 379 24 28
  51. Ch. des Maillettes       Fax : ++ 41 22 379 22 05
  1290 Sauverny             e-mail : yves.re...@epfl.ch
  SWITZERLAND                  Web : http://www.lunix.ch/revaz/
 


 --
 Download Intel#174; Parallel Studio Eval
 Try the new software tools for yourself. Speed compiling, find bugs
 proactively, and fine-tune applications for parallel performance.
 See why Intel Parallel Studio got high marks during beta.
 http://p.sf.net/sfu/intel-sw-dev
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar() and plt.title()

2010-04-04 Thread Claus
Hi,
I've got two questions: 
1) one is related to colorbar() on multiple subfigures (see code example 
below): how do I add a scatterplot if I wanted multiple subfigures? Or, what am 
I doing wrong in the second code example
2) in either of the examples, how can I increase the distance between the top 
of the plot (imshow) and the bottom of the title?


# code example 1: this works
fig = plt.figure()
plt.title('Hello')
plt.imshow(interpolValsRas, cmap=cm.jet, interpolation='nearest', origin = 
'lower', extent=[5,95,5,95]) # , 
plt.scatter(measurementLoc[:,0], measurementLoc[:,1], 10, messwerte, 
cmap=cm.jet)
plt.colorbar();


# code example 2: this works generally, but only if the second last line is 
commented out
# Q: how do I add a scatterplot if I wanted multiple subfigures?
fig = plt.figure()
ax = fig.add_subplot(111)
plt.title('Hello')
ax.imshow(interpolValsRas, cmap=cm.jet, interpolation='nearest', origin = 
'lower', extent=[5,95,5,95]) # , 
ax.scatter(measurementLoc[:,0], measurementLoc[:,1], 10, messwerte, cmap=cm.jet)
# plt.colorbar();
plt.show()

Thanks for your help,
Claus


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar() and plt.title()

2010-04-03 Thread Marius 't Hart
Try this:

from pylab import *
from numpy import *

Z = random.randn(100,100)

figure()
subplot(1,2,1)
imgHandle = imshow(Z, cmap=cm.gray)
scatter(random.rand(10)*100,random.rand(10)*100)
colorbar(imgHandle)
title('Hello')
show()

By the way, I find jet a bad colormap to represent scientific data: it 
suggests bands in the data that aren't there and when reduced to 
luminance (eg. students printing/copying in black/white or in the eyes 
of all your colorblind colleagues) the two halves of the scale are 
identical, rendering all graphs completely ambiguous. ;)


Claus wrote:
 Hi,
 I've got two questions: 
 1) one is related to colorbar() on multiple subfigures (see code example 
 below): how do I add a scatterplot if I wanted multiple subfigures? Or, what 
 am I doing wrong in the second code example
 2) in either of the examples, how can I increase the distance between the top 
 of the plot (imshow) and the bottom of the title?


 # code example 1: this works
 fig = plt.figure()
 plt.title('Hello')
 plt.imshow(interpolValsRas, cmap=cm.jet, interpolation='nearest', origin = 
 'lower', extent=[5,95,5,95]) # , 
 plt.scatter(measurementLoc[:,0], measurementLoc[:,1], 10, messwerte, 
 cmap=cm.jet)
 plt.colorbar();


 # code example 2: this works generally, but only if the second last line is 
 commented out
 # Q: how do I add a scatterplot if I wanted multiple subfigures?
 fig = plt.figure()
 ax = fig.add_subplot(111)
 plt.title('Hello')
 ax.imshow(interpolValsRas, cmap=cm.jet, interpolation='nearest', origin = 
 'lower', extent=[5,95,5,95]) # , 
 ax.scatter(measurementLoc[:,0], measurementLoc[:,1], 10, messwerte, 
 cmap=cm.jet)
 # plt.colorbar();
 plt.show()

 Thanks for your help,
 Claus
 --
 Download Intel#174; Parallel Studio Eval
 Try the new software tools for yourself. Speed compiling, find bugs
 proactively, and fine-tune applications for parallel performance.
 See why Intel Parallel Studio got high marks during beta.
 http://p.sf.net/sfu/intel-sw-dev
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
   


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar on LEFT side of figure ?

2010-03-04 Thread Jeff Whitaker
Jim Vickroy wrote:
 Hi,

 I have been unable to place a colorbar on the LEFT side of a figure.  
 For example, in the Gaussian noise with vertical colorbar 
 http://matplotlib.sourceforge.net/examples/pylab_examples/colorbar_tick_labelling_demo.html
  
 demo, how can the colorbar be positioned on the left side of the figure.

 Thanks,
 -- jv
   

Create your own axes instance for the colorbar (as in 
http://matplotlib.sourceforge.net/examples/pylab_examples/multi_image.html).

-Jeff

-- 
Jeffrey S. Whitaker Phone  : (303)497-6313
Meteorologist   FAX: (303)497-6449
NOAA/OAR/PSD  R/PSD1Email  : jeffrey.s.whita...@noaa.gov
325 BroadwayOffice : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar with date-time formatting

2010-01-15 Thread Jae-Joon Lee
Colorbar axes is a rather special and things need to be set during the
initialization.

Here is a slightly modified version of your script.

While it does not produces error, I'm not sure if the result is correct.

-JJ


import numpy as np
import matplotlib.pyplot as plt
from matplotlib.dates import DateFormatter,DayLocator
from matplotlib import cm

data = np.arange(24.)+70.
x = np.random.rand(24)
y = np.random.rand(24)
fig = plt.figure()
ax = fig.add_subplot(111)
smap = ax.scatter(x,y,s=10,c=data,edgecolors='none',marker='o',cmap=cm.jet)

cb = fig.colorbar(smap,orientation='horizontal',shrink=0.7,
  ticks=DayLocator(interval=5),
  format=DateFormatter('%b %d'))
plt.show()


On Thu, Jan 14, 2010 at 3:04 PM, George Nurser gnur...@googlemail.com wrote:
 Hi,
 I've got data in terms of day numbers, and wish to plot it as a 2D
 scatter plot, with the color denoting the day.

 I'd like the colorbar to be annotated in Apr 7 type format...

 I've tried the  following code without success.

 import numpy as np
 import matplotlib.pyplot as plt
 from matplotlib.dates import DateFormatter,DayLocator
 from matplotlib import cm

 data = np.arange(24.)+70.
 x = np.random.rand(24)
 y = np.random.rand(24)
 fig = plt.figure()
 ax = fig.add_subplot(111)
 smap = ax.scatter(x,y,s=10,c=data,edgecolors='none',marker='o',cmap=cm.jet)
 cb = fig.colorbar(smap,orientation='horizontal',shrink=0.7)
 cax=cb.ax
 cax.xaxis_date()
 cax.xaxis.set_major_locator(DayLocator())
 cax.xaxis.set_major_formatter(DateFormatter('%b %d'))
 plt.show()

 Any ideas on how to do this would be appreciated.

 George Nurser.

 The code fails with the trace
 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/backends/backend_wx.pyc
 in _onPaint(self, evt)
   1154         drawDC = wx.PaintDC(self)
   1155         if not self._isDrawn:
 - 1156             self.draw(drawDC=drawDC)
   1157         else:
   1158             self.gui_repaint(drawDC=drawDC)

 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/backends/backend_wxagg.pyc
 in draw(self, drawDC)
     57         
     58         DEBUG_MSG(draw(), 1, self)
 --- 59         FigureCanvasAgg.draw(self)
     60
     61         self.bitmap =
 _convert_agg_to_wx_bitmap(self.get_renderer(), None)

 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/backends/backend_agg.pyc
 in draw(self)
    386
    387         self.renderer = self.get_renderer()
 -- 388         self.figure.draw(self.renderer)
    389
    390     def get_renderer(self):

 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/artist.pyc
 in draw_wrapper(artist, renderer, *kl)
     53     def draw_wrapper(artist, renderer, *kl):
     54         before(artist, renderer)
 --- 55         draw(artist, renderer, *kl)
     56         after(artist, renderer)
     57

 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/figure.pyc
 in draw(self, renderer)
    770
    771         # render the axes
 -- 772         for a in self.axes: a.draw(renderer)
    773
    774         # render the figure text

 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/artist.pyc
 in draw_wrapper(artist, renderer, *kl)
     53     def draw_wrapper(artist, renderer, *kl):
     54         before(artist, renderer)
 --- 55         draw(artist, renderer, *kl)
     56         after(artist, renderer)
     57

 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/axes.pyc
 in draw(self, renderer, inframe)
   1759
   1760         for zorder, i, a in dsu:
 - 1761             a.draw(renderer)
   1762
   1763         renderer.close_group('axes')

 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/artist.pyc
 in draw_wrapper(artist, renderer, *kl)
     53     def draw_wrapper(artist, renderer, *kl):
     54         before(artist, renderer)
 --- 55         draw(artist, renderer, *kl)
     56         after(artist, renderer)
     57

 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/axis.pyc
 in draw(self, renderer, *args, **kwargs)
    747         renderer.open_group(__name__)
    748         interval = self.get_view_interval()
 -- 749         for tick, loc, label in self.iter_ticks():
    750             if tick is None: continue
    751             if not mtransforms.interval_contains(interval,
 loc): continue

 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/axis.pyc
 in iter_ticks(self)
    688         Iterate through all of the major and minor ticks.
    689         
 -- 690         majorLocs = self.major.locator()
    691         majorTicks = self.get_major_ticks(len(majorLocs))
    692         self.major.formatter.set_locs(majorLocs)

 

Re: [Matplotlib-users] Colorbar embedding in qt4

2010-01-07 Thread Alexander Hupfer
Hi, thanks for having a look at this.

Problem is that a scatter plot doesn't seem to have the option to actually
update the data, or at least I couldn't find it.

Is there maybe a way?

On Thu, Jan 7, 2010 at 2:58 AM, Laurent Dufrechou 
laurent.dufrec...@gmail.com wrote:

  Hi alexander,



 I tryed yesterday to play a little with your script.

 I suspect that in fact each time you draw a figure, it is added to a pool
 of figure to be rendered.

 Thus it goes slower and slower.



 What I do in my scritpt is either update the datas or if the drawing is a
 completely new one (like a polar ionstaed of log previously) I delete the
 figure.



 To update data use:



 1/self._plot, = axe.plot(x, y, 'b', animated=self._animated)



 Later:

 Loop:

 2/self._plot.set_ydata(self._value)





 If you need to delete your figure (that is not your case, but who knows for
 the future):

 axe = fig.add_axes(self.getPosition())

 …

 self._fig.delaxes(self._axe)



 To go even faster(x10) you have the blitting method, but set_ydata should
 be sufficent.



 Laurent



 *De :* Alexander Hupfer [mailto:son...@gmail.com]
 *Envoyé :* jeudi 7 janvier 2010 03:36
 *C**c :* matplotlib-users@lists.sourceforge.net
 *Objet :* Re: [Matplotlib-users] Colorbar embedding in qt4



 I isolated the problem a bit more. For some reason drawing gets slower and
 slower with each plot drawn.

 from os import sys
 from time import time
 from PyQt4 import QtGui, QtCore

 import matplotlib

 matplotlib.use('QT4Agg')

 from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as
 FigureCanvas
 from matplotlib.figure import Figure


 class MyMplCanvas(FigureCanvas):
 Ultimately, this is a QWidget (as well as a FigureCanvasAgg,
 etc.).
 def __init__(self, parent=None, width=5, height=4, dpi=100):
 fig = Figure(figsize=(width, height), dpi=dpi)
 self.axes = fig.add_subplot(111)
 # We want the axes cleared every time plot() is called
 self.axes.hold(False)

 self.compute_initial_figure()

 #
 FigureCanvas.__init__(self, fig)
 self.setParent(parent)

 FigureCanvas.setSizePolicy(self,
QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
 FigureCanvas.updateGeometry(self)

 def compute_initial_figure(self):
 pass

 class MyDynamicMplCanvas(MyMplCanvas):
 A canvas that updates itself every second with a new plot.
 def __init__(self, *args, **kwargs):
 MyMplCanvas.__init__(self, *args, **kwargs)
 timer = QtCore.QTimer(self)
 QtCore.QObject.connect(timer, QtCore.SIGNAL(timeout()),
 self.update_figure)
 timer.start(0)
 self.firstrun = True
 self.colorbar = None
 self.time = time()
 self.p = None
 def compute_initial_figure(self):
 pass

 def update_figure(self):
 self.p = self.axes.scatter([1,2,3],[4,5,6], c = range(3),
 animated=True)
 self.axes.set_xlabel('psi')
 self.axes.set_ylabel('delta')
 if self.firstrun == True:
 self.colorbar = self.axes.figure.colorbar(self.p)
 self.firstrun = False
 self.colorbar.set_clim(vmin=0,vmax=2)
 self.colorbar.draw_all()
 self.colorbar.set_label('time [abtr. ]')
 self.draw()
 newtime = time()
 print newtime - self.time
 self.time = newtime

 class ApplicationWindow(QtGui.QMainWindow):
 def __init__(self):
 QtGui.QMainWindow.__init__(self)
 self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

 self.main_widget = QtGui.QWidget(self)

 l = QtGui.QVBoxLayout(self.main_widget)

 dc = MyDynamicMplCanvas(self.main_widget, width=5, height=4,
 dpi=100)

 l.addWidget(dc)

 self.main_widget.setFocus()
 self.setCentralWidget(self.main_widget)


 qApp = QtGui.QApplication(sys.argv)

 aw = ApplicationWindow()
 aw.setWindowTitle(%s % Slow!)
 aw.setGeometry(100,100,800,600)
 aw.show()
 sys.exit(qApp.exec_())

 On Mon, Jan 4, 2010 at 3:36 PM, Alexander Hupfer son...@gmail.com wrote:

 Ok, here is the code as a whole. I think it's still short enough to
 ilustrate the problem. Just start it with the datafile elips as an
 argument

 http://dl.dropbox.com/u/226980/elipsometry.tar.gz

 The timer shows how long each render cycle takes. The time seems to grow
 with number of cycles rendered even when no more points are added (the
 points are calculated with a continous rate in a background thread and are
 about 300 total).



 On Sun, Jan 3, 2010 at 8:16 PM, John Hunter jdh2...@gmail.com wrote:

 On Sun, Jan 3, 2010 at 7:02 PM, Alexander Hupfer son...@gmail.com wrote:
  Thanks I got it fixed.
  This leads to the follow up question:
  What is the right way to keep an application responsive while the graph
 is
  drawn?
  Drawing a scatter plot with 300 points seems to take a while. I guess I
 need

Re: [Matplotlib-users] Colorbar embedding in qt4

2010-01-04 Thread Alexander Hupfer
Ok, here is the code as a whole. I think it's still short enough to
ilustrate the problem. Just start it with the datafile elips as an
argument

http://dl.dropbox.com/u/226980/elipsometry.tar.gz

The timer shows how long each render cycle takes. The time seems to grow
with number of cycles rendered even when no more points are added (the
points are calculated with a continous rate in a background thread and are
about 300 total).

On Sun, Jan 3, 2010 at 8:16 PM, John Hunter jdh2...@gmail.com wrote:

 On Sun, Jan 3, 2010 at 7:02 PM, Alexander Hupfer son...@gmail.com wrote:
  Thanks I got it fixed.
  This leads to the follow up question:
  What is the right way to keep an application responsive while the graph
 is
  drawn?
  Drawing a scatter plot with 300 points seems to take a while. I guess I
 need
  to launch the drawing in another thread but don't know exactly how to do
  this and only find examples of doing calculations in the background and
 not
  actual widget interaction.

 You posted some real code and a traceback, which helped move the ball
 forward.  What we really need to see to help you though is a complete,
 free-standing example, that we can run on our machines, which exposes
 the problem.

 JDH

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev ___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar embedding in qt4

2010-01-03 Thread John Hunter
On Sun, Jan 3, 2010 at 11:34 AM, Alexander Hupfer son...@gmail.com wrote:
 Hi, I have a scatter plot embedded in qt4 according to
 http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_qt4.html
 what works fine
 However if I try to add a colorbar to it by simply calling

 p = scatter()
 colorbar(p)

 I get an error that says that something is outside the drawable area.

Please post example code which replicates the problem and a full
traceback.  From the snippet you posted, it looks like you may be
using the pylab/pyplot interface which is not consistent with
embedding mpl in qt or any other widget set.  Rather, you need to be
using the mpl API.

JDH

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar embedding in qt4

2010-01-03 Thread Laurent Dufrechou
Hello,

You are using the TK backend.
Add this at the top of your script:

import matplotlib
matplotlib.use('QT4Agg')

from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as
FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as
NavigationToolbar

Should work.
(Or at least will no more show errors related to TK backend...)

Laurent
--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev ___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar embedding in qt4

2010-01-03 Thread Darren Dale
On Sun, Jan 3, 2010 at 5:26 PM, Alexander Hupfer son...@gmail.com wrote:
 Ok, that at least fixed the tkinter error, but I still don't get a colorbar
 attached to my plot. (which worked fine when I didn't embedd it in a Qt
 application)

If you are importing from pylab or pyplot in your program, don't.
These modules are not compatible with embedding.

Darren

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar embedding in qt4

2010-01-03 Thread Alexander Hupfer
Thanks I got it fixed.
This leads to the follow up question:
What is the right way to keep an application responsive while the graph is
drawn?
Drawing a scatter plot with 300 points seems to take a while. I guess I need
to launch the drawing in another thread but don't know exactly how to do
this and only find examples of doing calculations in the background and not
actual widget interaction.

- Alex

On Sun, Jan 3, 2010 at 3:37 PM, Darren Dale dsdal...@gmail.com wrote:

 On Sun, Jan 3, 2010 at 5:26 PM, Alexander Hupfer son...@gmail.com wrote:
  Ok, that at least fixed the tkinter error, but I still don't get a
 colorbar
  attached to my plot. (which worked fine when I didn't embedd it in a Qt
  application)

 If you are importing from pylab or pyplot in your program, don't.
 These modules are not compatible with embedding.

 Darren

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev ___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar embedding in qt4

2010-01-03 Thread Eric Firing
Alexander Hupfer wrote:
 Thanks I got it fixed.
 This leads to the follow up question:
 What is the right way to keep an application responsive while the graph 
 is drawn?
 Drawing a scatter plot with 300 points seems to take a while. I guess I 

That's strange--a scatter plot with 1000 points looks practically 
instantaneous to me.  Are you using the Axes.scatter method?

Eric


 need to launch the drawing in another thread but don't know exactly how 
 to do this and only find examples of doing calculations in the 
 background and not actual widget interaction.
 
 - Alex
 
 On Sun, Jan 3, 2010 at 3:37 PM, Darren Dale dsdal...@gmail.com 
 mailto:dsdal...@gmail.com wrote:
 
 On Sun, Jan 3, 2010 at 5:26 PM, Alexander Hupfer son...@gmail.com
 mailto:son...@gmail.com wrote:
   Ok, that at least fixed the tkinter error, but I still don't get
 a colorbar
   attached to my plot. (which worked fine when I didn't embedd it
 in a Qt
   application)
 
 If you are importing from pylab or pyplot in your program, don't.
 These modules are not compatible with embedding.
 
 Darren
 
 
 
 
 
 --
 This SF.Net email is sponsored by the Verizon Developer Community
 Take advantage of Verizon's best-in-class app development support
 A streamlined, 14 day to market process makes app distribution fast and easy
 Join now and get one step closer to millions of Verizon customers
 http://p.sf.net/sfu/verizon-dev2dev 
 
 
 
 
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar embedding in qt4

2010-01-03 Thread John Hunter
On Sun, Jan 3, 2010 at 7:02 PM, Alexander Hupfer son...@gmail.com wrote:
 Thanks I got it fixed.
 This leads to the follow up question:
 What is the right way to keep an application responsive while the graph is
 drawn?
 Drawing a scatter plot with 300 points seems to take a while. I guess I need
 to launch the drawing in another thread but don't know exactly how to do
 this and only find examples of doing calculations in the background and not
 actual widget interaction.

You posted some real code and a traceback, which helped move the ball
forward.  What we really need to see to help you though is a complete,
free-standing example, that we can run on our machines, which exposes
the problem.

JDH

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar with labels on top

2009-10-21 Thread Jae-Joon Lee
The api related to ticks and ticklabels is a bit confusing, at least
for me. So, often, it seems best to directly change the tick
properties.

for t in axcbar.xaxis.get_major_ticks():
t.tick1On = True
t.tick2On = True
t.label1On = False
t.label2On = True


-JJ


On Wed, Oct 21, 2009 at 11:24 AM, Thomas Robitaille
thomas.robitai...@gmail.com wrote:
 Hi,

 I'm trying to plot a horizontal colorbar with labels on top. I can use

 axcbar = fig.add_axes([0.2, 0.85, 0.6, 0.03])
 axcbar.xaxis.set_ticks_position('top')
 cbar = fig.colorbar(s, cax=axcbar, orientation='horizontal')

 but then I lose the ticks on the bottom of the colorbar. However,
 setting

 axcbar.xaxis.set_ticks_position('both')

 causes the labels to be on the bottom. Is there a way to have labels
 on the top while keeping ticks on both the top and bottom?

 Thanks,

 Thomas


 --
 Come build with us! The BlackBerry(R) Developer Conference in SF, CA
 is the only developer event you need to attend this year. Jumpstart your
 developing skills, take BlackBerry mobile applications to market and stay
 ahead of the curve. Join us from November 9 - 12, 2009. Register now!
 http://p.sf.net/sfu/devconference
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar tick label fontproperties

2009-09-22 Thread PHobson
John,

The following code works for me (Python 2.5.4, Matplotlib 0.99):

# create and format the colorbar
cbar = pl.colorbar(G, ticks=range(g1,g2+1))
cbar.ax.set_ylabel('Gradient (%)', fontsize=10)
cl = pl.getp(cbar.ax, 'ymajorticklabels')
pl.setp(cl, fontsize=10)

-Paul M. Hobson  


 -Original Message-
 From: John [H2O] [mailto:washa...@gmail.com]
 Sent: Tuesday, September 22, 2009 8:03 AM
 To: matplotlib-users@lists.sourceforge.net
 Subject: [Matplotlib-users] colorbar tick label fontproperties
 
 
 Could someone please explain how to change the font properties for a
 colorbar
 tick label, the following causes no error, but it does NOT work:
 
 ## CREATE COLORBAR
 ## make a copy of the image object
 im2 = copy.copy(im)
 im2.set_cmap(colmap)
 ## create new axis for colorbar.
 cax = plt.axes([l+w+0.03, b, 0.025, h-0.035])
 cb = plt.colorbar(im2, cax)#, format='%3.2g') # draw colorbar
 ## set colorbar label and ticks
 p_cax = mpl.font_manager.FontProperties(size='6')
 clabels = clevs[::10] ##clevs, by 10 steps
 clabels.append(clevs[-1]) ## add the last label
 cb.ax.set_yticks(np.linspace(0,1,len(clabels)))
 cb.ax.set_yticklabels(['%3.2g' % cl for cl in clabels],
 fontproperties=p_cax)
 cax.set_title('sensitivity\n(%s)' % units,
   fontproperties=p_cax)
 
 
 NOTE: It does set the title properties correctly.
 --
 View this message in context: http://www.nabble.com/colorbar-tick-
 label-fontproperties-tp25530779p25530779.html
 Sent from the matplotlib - users mailing list archive at Nabble.com.
 
 
 --
 
 Come build with us! The BlackBerryreg; Developer Conference in SF, CA
 is the only developer event you need to attend this year. Jumpstart
 your
 developing skills, take BlackBerry mobile applications to market and
 stay
 ahead of the curve. Join us from November 9#45;12, 2009. Register
 now#33;
 http://p.sf.net/sfu/devconf
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Come build with us! The BlackBerryreg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
http://p.sf.net/sfu/devconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar not working with specgram

2009-07-22 Thread davide lasagna
Thanks Eric for pointing out this. However i've found that psd and
specgram plot 10*log10*(Pxx/max(Pxx)), so i'll have a range from 0 db
down. 
Anyway, what do you mean by should not be axes method?
Do you mean using the array output of specgram and psd and plotting that
result by myself?

Cheers

Davide
On Tue, 2009-07-21 at 09:12 -1000, Eric Firing wrote:
 davide lasagna wrote:
  Hello everybody,
  this is my first post in this list. 
  
  I'm plotting a spectrogram with
  
  Pxx, freqs, bins, im = specgram(y, nfft=256, f_sampling=12000)
  
  and i want to add a colorbar with
  
  colorbar()
  
  
  The problem is that the color scale seems to be wrong with respect to
  the data in Pxx, i.e. Pxx is of the order of 1e-2 while in the colorbar
  i have tick values spanning from -20 to -180. What is the problem??
 
 specgram and psd plot power in decibels: 10*log10(Pxx).
 
 Because they involve heavy computation and application-specific choices, 
 like the decibel scale, they really should not be axes methods.
 
 You can make a function plot the spectrogram however you like by looking 
 at the source code in the Axes.specgram method (the pyplot specgram 
 function is just a thin wrapper for this method), which is using 
 mlab.specgram to do the calculation and is then just scaling and plotting.
 
 Eric
 
 
  
  Thanks in advance!
  
  
  Davide
  
  
  --
  Enter the BlackBerry Developer Challenge  
  This is your chance to win up to $100,000 in prizes! For a limited time, 
  vendors submitting new applications to BlackBerry App World(TM) will have
  the opportunity to enter the BlackBerry Developer Challenge. See full prize 
   
  details at: http://p.sf.net/sfu/Challenge
  ___
  Matplotlib-users mailing list
  Matplotlib-users@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 


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


Re: [Matplotlib-users] Colorbar not working with specgram

2009-07-22 Thread Eric Firing
davide lasagna wrote:
 Thanks Eric for pointing out this. However i've found that psd and
 specgram plot 10*log10*(Pxx/max(Pxx)), so i'll have a range from 0 db
 down. 
Aha, I wasn't looking closely enough!

 Anyway, what do you mean by should not be axes method?
That was a side remark about what the Axes class should do or not do. I 
would prefer that it stick to plotting.  For example, at present it does 
not have a method for empirical orthogonal functions, or for 
wavelets--and that's good, it shouldn't.  Numerical code (usually in 
numpy or scipy) should do the calculations, and then the result should 
be plotted using Axes methods or pyplot functions for line plotting, 
contouring, making images, etc.  So getting back to the specgram, I 
would prefer that it be given as an example--a script combining the 
calculation with the plotting--rather than having calculation and 
plotting done in an Axes method.
 Do you mean using the array output of specgram and psd and plotting that
 result by myself?

The calculations are being done by functions in the matplotlib.mlab 
module, so yes, I suggest using those functions directly (not the pyplot 
functions that wrap the Axes methods that call the mlab functions and 
then plot the result) and then doing your own scaling and plotting.  The 
Axes specgram method might guide you in the latter (giving an example of 
how to use imshow, for example), but if you write your own function you 
can make it do exactly what you want instead of accepting the scaling 
choice imposed by the Axes method.

Eric

 
 Cheers
 
 Davide
 On Tue, 2009-07-21 at 09:12 -1000, Eric Firing wrote:
 davide lasagna wrote:
 Hello everybody,
 this is my first post in this list. 

 I'm plotting a spectrogram with

 Pxx, freqs, bins, im = specgram(y, nfft=256, f_sampling=12000)

 and i want to add a colorbar with

 colorbar()


 The problem is that the color scale seems to be wrong with respect to
 the data in Pxx, i.e. Pxx is of the order of 1e-2 while in the colorbar
 i have tick values spanning from -20 to -180. What is the problem??
 specgram and psd plot power in decibels: 10*log10(Pxx).

 Because they involve heavy computation and application-specific choices, 
 like the decibel scale, they really should not be axes methods.

 You can make a function plot the spectrogram however you like by looking 
 at the source code in the Axes.specgram method (the pyplot specgram 
 function is just a thin wrapper for this method), which is using 
 mlab.specgram to do the calculation and is then just scaling and plotting.

 Eric


 Thanks in advance!


 Davide


 --
 Enter the BlackBerry Developer Challenge  
 This is your chance to win up to $100,000 in prizes! For a limited time, 
 vendors submitting new applications to BlackBerry App World(TM) will have
 the opportunity to enter the BlackBerry Developer Challenge. See full prize 
  
 details at: http://p.sf.net/sfu/Challenge
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 
 
 --
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


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


Re: [Matplotlib-users] Colorbar Ticks

2009-05-25 Thread marcusantonius

I should perhaps mention, that if i try
cbar=fig.colorbar(p1,orientation='horizontal',ticks=[0.0,2.0,4.0,6.0,8.0])
cbar.ax.set_xticklabels(['0', '2', '4','6','8'])
the colorbar is drawn correctly, but I get the label 0 at position 2, the
label 2 at position 4 and 4 at pos. 6, the labels at the end are not
drawn...

-- 
View this message in context: 
http://www.nabble.com/Colorbar-Ticks-tp23712716p23712944.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar Ticks

2009-05-25 Thread Eric Firing
marcusantonius wrote:
 Hello,
 
 I have the problem, that sometimes the first and last ticklabel of a
 colorbar is not drawn. E.g. if I create a colorbar through
 fig.colorbar(p3,orientation='horizontal',ticks=np.arange(0.0,8,2))
 I only get ticklabels at 2,4,6, but I would like it to have 0,2,4,6,8 and I
 don't know how to control this behaviour. If I do
 cb=fig.colorbar(p3,orientation='horizontal',ticks=np.arange(0.0,8,2))
 cb.ax.xaxis.set_ticks(np.arange(0,8,2))
 the colorbar vanishes and instead I have 4 ticks with the labels
 0.8,1.6,2.4,3.2
 
 Thank you for your help,
 Markus
 
 

Markus,

The problem here is not the specification of the ticks, it is the actual 
range of the colorbar, which is taken from the norm object used in the 
color mapping.  Try this (in ipython -pylab):

imshow(rand(10,10)*8, vmin=0, vmax=8)
colorbar(ticks=[0,2,4,6,8])

Alternatively, you can use the set_clim() method on any Mappable such as 
an image, or the pyplot clim() function, to set the limits.

Note also that to get the sequence [0,2,4,6,8] you need arange(0,9,2), 
not arange(0,8,2).  Or you can use linspace(0,8,5) if you prefer.

Eric



--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar Ticks

2009-05-25 Thread Eric Firing
marcusantonius wrote:
 I should perhaps mention, that if i try
 cbar=fig.colorbar(p1,orientation='horizontal',ticks=[0.0,2.0,4.0,6.0,8.0])

The ticks that it uses are taken from the list--they are the ones that 
are within the range of numbers mapped to colors.  The list of ticks 
does not set that range.

 cbar.ax.set_xticklabels(['0', '2', '4','6','8'])
Setting ticklabels is dangerous unless you do it based on first getting 
the actual ticks and using their values, or if you are otherwise sure of 
their values.  But it should be very rare that you have to do this.

 the colorbar is drawn correctly, but I get the label 0 at position 2, the
 label 2 at position 4 and 4 at pos. 6, the labels at the end are not
 drawn...

None of the labels correspond to their ticks in this case.

Eric




--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar Ticks

2009-05-25 Thread marcusantonius

Thank you very much for your email.

Your example
imshow(rand(10,10)*8, vmin=0, vmax=8)
colorbar(ticks=[0,2,4,6,8])
works fine.

Note also that to get the sequence [0,2,4,6,8] you need arange(0,9,2), 
not arange(0,8,2).  Or you can use linspace(0,8,5) if you prefer.
Thank you for making me aware of that (You see that I don't have a lot of
experience in python and matplotlib).

I now specified the color range via vmin and vmax, and this solved my
problem. Thanks for the fast help

-- 
View this message in context: 
http://www.nabble.com/Colorbar-Ticks-tp23712716p23713404.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar for pcolor plot

2009-05-20 Thread John Hunter
On Wed, May 20, 2009 at 9:53 AM, Ryan May rma...@gmail.com wrote:

 Thanks for the full example, but if you carefully read the exception, it was
 telling you the problem. :)  plot1 here is an axes object, which does not
 have a colorbar() method.  Instead, you should change that to:

 plt.colorbar()

 Assuming everything else was working, you should be good to go with this
 change.


It looks like Markus is trying to use the API, so rather than suggest
the pyplot colorbar method, I suggest using the figure instance
method.  Markus the pyplot method plt.colorbar is a thin wrapper
around the figure method fig.colorbar -- see also:

  
http://matplotlib.sourceforge.net/faq/usage_faq.html#matplotlib-pylab-and-pyplot-how-are-they-related

  
http://matplotlib.sourceforge.net/api/figure_api.html#matplotlib.figure.Figure.colorbar

It may be a good idea and refer to the return value of fig.add_subplot
as ax or something that, rather than plot1 because add_subplot
returns an Axes instance and thus ax is a better mnemonic; see

  
http://matplotlib.sourceforge.net/api/figure_api.html#matplotlib.figure.Figure.add_subplot

So I suggest something like::

fig = plt.figure()

ax1 = fig.add_subplot(231,aspect='equal')
ax1.pcolor(xsr)
ax1.axis([0, 127, 0, 127])
fig.colorbar()

JDH

--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar for pcolor plot

2009-05-20 Thread Ryan May
On Wed, May 20, 2009 at 10:04 AM, John Hunter jdh2...@gmail.com wrote:

 On Wed, May 20, 2009 at 9:53 AM, Ryan May rma...@gmail.com wrote:

  Thanks for the full example, but if you carefully read the exception, it
 was
  telling you the problem. :)  plot1 here is an axes object, which does not
  have a colorbar() method.  Instead, you should change that to:
 
  plt.colorbar()
 
  Assuming everything else was working, you should be good to go with this
  change.
 

 It looks like Markus is trying to use the API, so rather than suggest
 the pyplot colorbar method, I suggest using the figure instance
 method.  Markus the pyplot method plt.colorbar is a thin wrapper
 around the figure method fig.colorbar -- see also:


 http://matplotlib.sourceforge.net/faq/usage_faq.html#matplotlib-pylab-and-pyplot-how-are-they-related


 http://matplotlib.sourceforge.net/api/figure_api.html#matplotlib.figure.Figure.colorbar

 It may be a good idea and refer to the return value of fig.add_subplot
 as ax or something that, rather than plot1 because add_subplot
 returns an Axes instance and thus ax is a better mnemonic; see


 http://matplotlib.sourceforge.net/api/figure_api.html#matplotlib.figure.Figure.add_subplot

 So I suggest something like::

fig = plt.figure()

ax1 = fig.add_subplot(231,aspect='equal')
ax1.pcolor(xsr)
ax1.axis([0, 127, 0, 127])
fig.colorbar()


Except that it won't work like that. :) (I actually tried that the first
time) You need to give Figure.colorbar() the mappable as the first
argument.  So this would then become:

ax1 = fig.add_subplot(231,aspect='equal')
pc = ax1.pcolor(xsr)
ax1.axis([0, 127, 0, 127])
fig.colorbar(pc)

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
Sent from Norman, Oklahoma, United States
--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar with 2 different scales

2009-04-06 Thread Eric Firing
P.Romero wrote:
 Is it possible to create a colorbar with different scales on each side?
 
  
 
 Example:
 
  a temperature colorbar with celcius values on the left side and 
 farenheit values on the right side.
 
  
 
 If so, how could this be done?

A colorbar is just an axes object with some customization of the ticks 
and labels, and with a pcolor plot inside.  You could get your second 
scale using a technique similar to the twinx and twiny Axes methods; you 
can then use set_xlim or set_ylim so that the Fahrenheit range on the 
new axes matches the Celcius range on the old one.

To get started, look at the source for the twinx/twiny methods.

Eric

 
  
 
 Please help,
 
 Thanks,
 
 P.Romero
 
 
 
 
 --
 This SF.net email is sponsored by:
 High Quality Requirements in a Collaborative Environment.
 Download a free trial of Rational Requirements Composer Now!
 http://p.sf.net/sfu/www-ibm-com
 
 
 
 
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar tick labeling

2008-11-20 Thread Eric Firing
Michael Outhouse wrote:
 I was wondering if it is possible to change the colorbar tick labeling in 
 matplotlib from numeric to text. Essentially, I want the colorbar to be a 
 qualitative indicator; in the jet scheme, I'd like blue to be labeled 
 as 'unstable', green as 'neutral', and red as 'stable'. I can change it so I 
 just show the underlying values - colorbar(ticks = (-1, 0, 1)), but I cannot 
 change the the tick labels to text. Is there any way to accomplish this? 
 Thanks in advance for any help.

Your message came more than a month ago, but it looks like no one 
answered, so here is an answer:

with ipython -pylab:

imshow(2*rand(10,10) - 1, vmin=-1, vmax=1)
cbar = colorbar(ticks=[-1,0,1])
cbar.ax.set_yticklabels(['unstable', 'neutral', 'stable'])
draw()

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK  win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar tick labeling

2008-11-20 Thread Scott Sinclair
2008/11/21 Eric Firing [EMAIL PROTECTED]:
 Michael Outhouse wrote:
 I was wondering if it is possible to change the colorbar tick labeling in
 matplotlib from numeric to text. Essentially, I want the colorbar to be a
 qualitative indicator; in the jet scheme, I'd like blue to be labeled
 as 'unstable', green as 'neutral', and red as 'stable'. I can change it so I
 just show the underlying values - colorbar(ticks = (-1, 0, 1)), but I cannot
 change the the tick labels to text. Is there any way to accomplish this?
 Thanks in advance for any help.

 Your message came more than a month ago, but it looks like no one
 answered, so here is an answer:

 with ipython -pylab:

 imshow(2*rand(10,10) - 1, vmin=-1, vmax=1)
 cbar = colorbar(ticks=[-1,0,1])
 cbar.ax.set_yticklabels(['unstable', 'neutral', 'stable'])
 draw()

Also see the example here
http://matplotlib.sourceforge.net/examples/pylab_examples/colorbar_tick_labelling_demo.html.

Cheers,
Scott

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK  win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar() fix limit on Heat map

2008-08-11 Thread Jeff Whitaker
stuartornum wrote:
 Hi All,

 You may remember from my previous post I was having problems plotting a
 heatmap, however Pete came through for me and made it work.

 Anyway, I have almost finished what I want to do. The only issue is fixing
 the colorbar() range limit.

 Sometimes the my values are 0.01 to 0.2 for example, and other times there
 0.01 to 0.99.

 So what happens it the colorbar() automagically adjusts the gradient
 according to my values, however I do not want it to do that, I want the
 graph to be consistantly 0 - 1 (blue - red).

 I have tried things like colorbar(0,1), however no luck.

 If you could let me know how to fix the range, I would be very grateful.

 Regards
   
Stuart:  Use the vmin/vmax keyword arguments if your are using imshow or 
pcolor/pcolormesh.  If you are using contourf,  just specify the contour 
levels to span the range 0-1 (i.e. clevs=linspace(-1,1,15)).

-Jeff

-- 
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC  R/PSD1FAX   : (303)497-6449
325 BroadwayBoulder, CO, USA 80305-3328


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK  win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar() fix limit on Heat map

2008-08-11 Thread Jeff Whitaker
stuartornum wrote:
 Jeff,

 That worked perfectly ! Thank you.

 One more question... how would I change the colour scheme of the colorbar()?

 Thanks again
   
Stuart:  Use the cmap argument to specify a color map.

Have you checked out the pylab examples?  For me, they are the best way 
to learn how to use matplotlib effectively.

-Jeff


-- 
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC  R/PSD1FAX   : (303)497-6449
325 BroadwayBoulder, CO, USA 80305-3328


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK  win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] ColorBar with axes

2008-07-31 Thread Eric Firing
[EMAIL PROTECTED] wrote:
 Hello,
 
 I would like to show a colorbar for my plot (see attachment) but I can't
 figure out how it works.
 In the examples on the website I only found the call to pylab.colorbar(),
 which doesn't work with my subplots. My code is as follows (with the bar
 graph-part snipped, for brevity). I also tried the ColorBar class and
 assigning cmap=cm.jet but it didn't work. Could anybody give me a hint
 please? I searched the tutorial, cookbook, api reference and google, but I
 can't really find anything.
 
 Thanks,
 Felix
 
 fig = p.figure()
 fig.text(0.5, 0.94, main_title, fontsize=x-large, ha=center)
 
 (...bar graph part snipped...)
 
 ax = fig.add_subplot(222)
 ax.set_title('Euclidean Distance')
 matrix = n.zeros([numof_dicts, numof_dicts])
 for i1, d1 in enumerate(dictionaries):
 for i2, d2 in enumerate(dictionaries):
 for k in d1.keys():
 if d2.has_key(k):
prob1 = (d1[k] / vectorlengths[i1])
prob2 = (d2[k] / vectorlengths[i2])
matrix[i1, i2] += prob1 * prob2
 ax.imshow(matrix, interpolation=nearest, cmap=p.cm.jet)

im = ax.imshow(matrix, interpolation=nearest, cmap=p.cm.jet)
p.colorbar(im, ax=ax)

Try the above, possibly adding a shrink kwarg; if you don't like the 
axes splitting that colorbar does by default, then you can make an axes 
to taste, call it cax, and instead of specifying the image axes as 
above, use p.colorbar(im, cax=cax).

Eric

 if documentnames != None:
 ax.set_yticklabels(documentnames, va=center, fontsize='x-small')
 ax.set_yticks(range(numof_dicts))
 #p.colorbar()
 
 ax = fig.add_subplot(224)
 ax.set_title('Kullback Leibler Distance')
 ax.imshow(matrix, interpolation=nearest)
 
 if documentnames != None:
 ax.set_yticklabels(documentnames, va=center, fontsize='x-small')
 ax.set_yticks(range(numof_dicts))
 ax.set_xticklabels(documentnames, rotation=320, va=top, ha=left,
 fontsize='xx-small')
 ax.set_xticks(range(numof_dicts))
 
 fig.subplots_adjust(left=0.10, right=0.90, top=0.90, bottom=0.24,
 hspace=0.3,wspace=0.9)
 fig.set_size_inches(13, 10.5)
 fig.savefig(sys.argv[1] + _statistics.png)
 #p.show()

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK  win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar()

2008-06-21 Thread Eric Firing
Bryan Fodness wrote:
 Is there a way to get the colorbar to work with an axes instance.
  
 ax2 = axes([0.2, 0.1, 0.6, 0.8], axisbg='w')
 ax2.fill([x1,x2,x2,x1], [y1,y1,y2,y2], fc='None', ec='r')
 ax2.pcolormesh(X, Y, newa, shading='flat', cmap=cm.YlOrRd)#gray_r) 
 ax2.axvline(x=0, color='gray', linestyle='--')
 ax2.axhline(y=0, color='gray', linestyle='--')
 ax2.plot([offaxisX], [offaxisY], 'r+', mew=1)
 ax2.colorbar()
  
 AttributeError: 'Axes' object has no attribute 'colorbar'

Bryan,

A colorbar is a plot in its own axes, so just as a figure has an 
add_subplot method to add a general-purpose axes, it has a colorbar 
method to add a special-purpose axes with a colorbar in it.

One way to modify your example is something like this (untested):

ax2 = axes([0.2, 0.1, 0.6, 0.8], axisbg='w')
ax2.fill([x1,x2,x2,x1], [y1,y1,y2,y2], fc='None', ec='r')
# Save the mappable returned by pcolormesh:
pcm = ax2.pcolormesh(X, Y, newa, shading='flat', cmap=cm.YlOrRd)#gray_r)
ax2.axvline(x=0, color='gray', linestyle='--')
ax2.axhline(y=0, color='gray', linestyle='--')
ax2.plot([offaxisX], [offaxisY], 'r+', mew=1)
# Call the figure method, give it the mappable:
ax2.get_figure().colorbar(pcm, ax=ax2)

This will steal space from ax2 to make the colorbar axes.  If you want 
to make the colorbar axes yourself, called ax_cbar, for example, then
the last line would be

ax2.get_figure().colorbar(pcm, cax=ax_cbar)

Of course, if you make the figure at the start, and save the reference 
to it, then you can use that reference in place of ax2.get_figure()

Eric


  
 colorbar()
  
 , line 499, in module
 colorbar()
   File C:\Python25\Lib\site-packages\matplotlib\pyplot.py, line 1129, 
 in colorbar
 ret = gcf().colorbar(mappable, cax = cax, ax=ax, **kw)
   File C:\Python25\Lib\site-packages\matplotlib\figure.py, line 956, 
 in colorbar
 cb = cbar.Colorbar(cax, mappable, **kw)
   File C:\Python25\Lib\site-packages\matplotlib\colorbar.py, line 558, 
 in __init__
 mappable.autoscale_None() # Ensure mappable.norm.vmin, vmax
 AttributeError: 'NoneType' object has no attribute 'autoscale_None'
  
 I am not sure how the mappable, ax, and cax options work.

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar

2008-06-20 Thread Yves Revaz
Ryan May wrote:
 Yves Revaz wrote:
   
 Hi all,

 When I use:

 colorbar(orientation='horizontal')

 the color bar is drawn on the bottom of the corresponding graph.
 Which option will draw the colorbar on the top of the graph ?
 

 I think (correct me if I'm wrong devs) you'll have to use the cax
 keyword argument to manually specifiy the position of the axes in which
 to draw the colorbar.  You'll also need to adjust the position of the
 plot using figure.subplots_adjust.  Like this maybe:

 import numpy as np
 import matplotlib.pyplot as plt
 data = np.random.randn(30,30)
 plt.pcolor(data)
 fig = plt.gcf()
 fig.subplots_adjust(top=0.85)
 ax = fig.add_axes([0.12, 0.9, 0.8, 0.05])
 plt.colorbar(cax=ax, orientation='horizontal')

 Hope this helps,

   

ok, it works fine for that case.
Now, my problem is that my graph is a subplot:
Taking your example it corresponds to :

import numpy as np
import matplotlib.pyplot as plt

fig = plt.gcf()

plt.subplot(2,2,2)
data = np.random.randn(30,30)
plt.pcolor(data)

fig.subplots_adjust(top=0.85)
ax = fig.add_axes([0.12, 0.9, 0.8, 0.05])
plt.colorbar(cax=ax, orientation='horizontal')

plt.show()


Obviously, the colorbar has now the length of the whole figure and not
the one
of the subplot !  :-( 
I should do a subplots_adjust to the subplot and not to the fig, but
how can I do that ?

Thanks,

yves

 Ryan

 --
 Ryan May
 Graduate Research Assistant
 School of Meteorology
 University of Oklahoma
   


-- 
 (o o)
oOO--(_)--OOo---
  Yves Revaz
  Laboratory of Astrophysics EPFL
  Observatoire de Sauverny Tel : ++ 41 22 379 24 28
  51. Ch. des Maillettes   Fax : ++ 41 22 379 22 05
  1290 Sauverny e-mail : [EMAIL PROTECTED]
  SWITZERLAND  Web : http://www.lunix.ch/revaz/



-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar

2008-06-18 Thread Ryan May
Yves Revaz wrote:
 Hi all,
 
 When I use:
 
 colorbar(orientation='horizontal')
 
 the color bar is drawn on the bottom of the corresponding graph.
 Which option will draw the colorbar on the top of the graph ?

I think (correct me if I'm wrong devs) you'll have to use the cax 
keyword argument to manually specifiy the position of the axes in which 
to draw the colorbar.  You'll also need to adjust the position of the 
plot using figure.subplots_adjust.  Like this maybe:

import numpy as np
import matplotlib.pyplot as plt
data = np.random.randn(30,30)
plt.pcolor(data)
fig = plt.gcf()
fig.subplots_adjust(top=0.85)
ax = fig.add_axes([0.12, 0.9, 0.8, 0.05])
plt.colorbar(cax=ax, orientation='horizontal')

Hope this helps,

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar problem

2008-03-11 Thread humufr
Le Sunday 09 March 2008 14:32:05 Eric Firing, vous avez écrit :
 [EMAIL PROTECTED] wrote:
  Hello,
 
  I have some stupid questions about how to use colorbar.
 
  1) I would like to be able to put the colorbar where I went: top, bottom,
  left, right. For what I see I can do only a vertical left and horizontal
  bottom ones (with a simple use of the function).
  I know that it's possible to do a colorbar only but it's difficult to
  place them a little bit automatically and that bring my second question.

 This looks like a feature request: instead of specifying horizontal or
 vertical, be able to specify top, bottom, left, or right.
 This is fairly easy in principle, but there are some wrinkles such that
 I am not sure it would be satisfactory in practice--some custom
 adjustments might usually be needed depending on whether the main axes
 have a title (in the case of top) or an xlabel (in the case of
 left).  You may be better off simply figuring out what main and
 colorbar axes positions work best for your particular case and then
 making those axes explicitly.

I agree it's more feature request. I'll look on how to implement your 
suggestion. 

  2) I would like that the colorbar with exactly the same size than the
  image I plot with pcolor. It's working when I'm not using the
  aspect='equal' in the subplot but not with this option. Naturally I want
  to not change the aspect of my image and so it's a big problem for me.
  The only solution I found is to manipulate the colorbar with the shrink
  valu but it's a little bit painfull especially the value change for each
  pcolor image (they doesn't have always the same size).

 This is a common request, and a reasonable one, but unfortunately it is
 not straightforward to implement automatically given mpl's internal
 structure.  Again, however, you get the desired result quite easily by
 creating your own axes explicitly.

This is what I was afraid... So I have a stupid question but how to do this, 
create the axes at the same place than the pcolor image?

I can see how I can recuperate the axes coordinates but I don't know how to 
use them:

im = pylab.pcolor(a)
ax = im.get_axes()
cs = pylab.colorbar()

but after I'm a little bit lost...

  3) I would like to give a label to the colorbar (ie if the colorbar is at
  the bottom a label under the colorbar etc). To tell people what means the
  colors but I didn't find anyway to do it. xlabel work for the pcolor
  object (as expected) and there are no colorbar.xlabel function.

 Use the set_label() method.
 ...
 cbar = fig1.colorbar(im,orientation='horizontal')
 cbar.set_label('label')
 ...

Great thanks it's working perfectly.

 Eric

Thank you for your help,

N.


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar problem

2008-03-09 Thread Eric Firing
[EMAIL PROTECTED] wrote:
   Hello,
 
 I have some stupid questions about how to use colorbar.
 
 1) I would like to be able to put the colorbar where I went: top, bottom, 
 left, right. For what I see I can do only a vertical left and horizontal 
 bottom ones (with a simple use of the function).
 I know that it's possible to do a colorbar only but it's difficult to place 
 them a little bit automatically and that bring my second question.

This looks like a feature request: instead of specifying horizontal or 
vertical, be able to specify top, bottom, left, or right. 
This is fairly easy in principle, but there are some wrinkles such that 
I am not sure it would be satisfactory in practice--some custom 
adjustments might usually be needed depending on whether the main axes 
have a title (in the case of top) or an xlabel (in the case of 
left).  You may be better off simply figuring out what main and 
colorbar axes positions work best for your particular case and then 
making those axes explicitly.

 
 2) I would like that the colorbar with exactly the same size than the image I 
 plot with pcolor. It's working when I'm not using the aspect='equal' in the 
 subplot but not with this option. Naturally I want to not change the aspect 
 of my image and so it's a big problem for me. The only solution I found is to 
 manipulate the colorbar with the shrink valu but it's a little bit painfull 
 especially the value change for each pcolor image (they doesn't have always 
 the same size).

This is a common request, and a reasonable one, but unfortunately it is 
not straightforward to implement automatically given mpl's internal 
structure.  Again, however, you get the desired result quite easily by 
creating your own axes explicitly.

 
 3) I would like to give a label to the colorbar (ie if the colorbar is at the 
 bottom a label under the colorbar etc). To tell people what means the colors 
 but I didn't find anyway to do it. xlabel work for the pcolor object (as 
 expected) and there are no colorbar.xlabel function.

Use the set_label() method.
...
cbar = fig1.colorbar(im,orientation='horizontal')
cbar.set_label('label')
...

Eric

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar requires mappable?

2008-03-08 Thread Eric Firing
Ryan,

See examples/colorbar_only.py.  I think it illustrates what you want.

Eric

Ryan May wrote:
 Hi,
 
 In working on creating updating pcolor plots, I noticed that I can't 
 create colorbars (which should be static) without first displaying an 
 image.  I have a fixed Normalize object and colormap, so I would think 
 that the colorbar wouldn't actually need any information from the image 
 itself.
 
 Is there any to create a colorbar without first actually plotting an 
 image?  If not, is there any reason colorbar couldn't be modified to 
 work using only a norm and a cmap?
 
 Thanks,
 
 Ryan
 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar and set_under

2008-01-16 Thread Eric Firing
Carol Leger wrote:
 Hi folks,
 
 I have encountered a problem using colorbar and set_under with a color 
 map that has only 32 colors.  The downward arrow is not filled with the 
 correct color.  If 64 colors are used, the arrow is filled correctly.  I 
 actually want 8 colors.
 
 The test code is essentially image_masked.py from the 0.90.0 examples.
 
 if I use: palette = cm.get_cmap(gray, 64)
 the plot is OK.
 if I use: palette = cm.get_cmap(gray, 32)
 it is not OK.
 
 In both cases, the upper arrow is the correct color.
 
 I am using matplotlib version 0.90.0.

Carol,

It works for me even with 8 colors, using the svn version of mpl.  There 
have been a lot of changes between 0.90.0 and the present svn trunk 
(including a heart transplant by Mike D.), but I would not have expected 
any changes that would change the behavior you describe.  I can't think 
of any way a bug would have made a break point in behavior between 32 
and 64 colors.  I'm baffled.

Can you install and run the svn version?  Or the latest release (which 
does not include the new heart)?  I also tried the svn maintenance 
branch, which is virtually identical to the last release, and it works 
the same as the trunk.

Eric

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar, setting limits

2007-03-27 Thread Evan Mason

Sorry, I realise that my example in my original post doesn't quite make
sense.  My data range is 17 to 23.  I set clim to be clim([15, 25]).  I then
want the colorbar limits to be the same as clim, 15 to 25.  The questions
remains the same, which is how to set the range for colorbar.

Thanks, Evan
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar, setting limits

2007-03-27 Thread Eric Firing
Evan,

It is still not quite clear to me what you want versus what you are 
getting.  With recent versions of mpl, the colorbar automatically uses 
the same color boundaries as contourf, if that is what the colorbar is 
tracking.  What version of mpl are you using?

(With the most recent mpl I see that there is a strange bug such that 
setting clim clobbers the axis tick labeling for the colorbar--yet 
another thing that needs to be figured out and fixed.)

Eric

Evan Mason wrote:
 Sorry, I realise that my example in my original post doesn't quite make 
 sense.  My data range is 17 to 23.  I set clim to be clim([15, 25]).  I 
 then want the colorbar limits to be the same as clim, 15 to 25.  The 
 questions remains the same, which is how to set the range for colorbar.
 
 Thanks, Evan

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar, setting limits

2007-03-27 Thread Evan Mason

Hi Eric

I am using matplotlib-0.90.0.

I am making 2 contourf subplots of temperature values which have similar but
not equal ranges.  In subplot1 the range is 15-25; in subplot2 it is 16 to
24.  I use clim, giving it the max and min values obtained from a comparison
of subplot1 and 2; i.e., I use clim([15, 25]) on both subplots.  The two
subplots display exactly as I want them to.

Next, I want 2 colorbars to go with the two subplots.  I want the range of
each colorbar to be the same, set as the clim values (15 and 25).  This
happens for subplot1, but not for subplot2, which shows the range 16-24,
following its input data range and not the clim values.

So what I want to know is if it is possible to overide the colorbar limits,
setting them to 15-25?

I hope that's clearer now, thanks, Evan



On 3/27/07, Eric Firing [EMAIL PROTECTED] wrote:


Evan,

It is still not quite clear to me what you want versus what you are
getting.  With recent versions of mpl, the colorbar automatically uses
the same color boundaries as contourf, if that is what the colorbar is
tracking.  What version of mpl are you using?

(With the most recent mpl I see that there is a strange bug such that
setting clim clobbers the axis tick labeling for the colorbar--yet
another thing that needs to be figured out and fixed.)

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar, ax.get_position after figsize changed by ax.set_aspect

2006-10-05 Thread Eric Firing
George Nurser wrote:
 I have been trying to
 i. plot a figure using pcolormesh
 ii. set the proportions of the figure using ax.set_aspect
 iii. draw colorbar
 
 Problem is, colorbar height uses whole of axes box, not just height of
 figure (whose proportions were set by call of
 ax.set_aspect(aspect=2.,adjustable='box')).
 
 I can't set the colorbar height manually either, as I don't know how
 to get out the bounding box of the figure -- ax.get_position() just
 gives the full axes box, which is unaffected by ax.set_aspect.
 
 Is there any way of recovering the actual bounding box of the figure?
 The docstring for the method ax.set_position says:
 
 There are two position variables: one which is ultimately
 used, but which may be modified by apply_aspect, and a second
 which is the starting point for apply_aspect.
 
 which = 'active' to change the first;
 'original' to change the second;
 'both' to change both
 
 which sounds relevant, but these variables don't seem to apply to
 ax.get_position()

George,

The problem with your attempt to use get_position() is that the aspect 
ratio does not affect the position until the apply_aspect method of the 
axes is called, which is normally when drawing occurs.  You can either 
call it yourself, or you can insert a draw command.  Here is an example 
of the first:

In [6]:pcolor(z)
Out[6]:matplotlib.collections.PolyCollection instance at 0xb3db690c

In [7]:gca().get_position()
Out[7]:[0.125, 0.099978, 0.77502, 
0.80004]

In [8]:gca().set_aspect(3)

In [9]:gca().get_position()
Out[9]:[0.125, 0.099978, 0.77502, 
0.80004]

In [10]:clf()

In [11]:pcolor(z)
Out[11]:matplotlib.collections.PolyCollection instance at 0xb3dc6a6c

In [12]:gca().get_position()
Out[12]:[0.125, 0.099978, 0.77502, 
0.80004]

In [13]:gca().set_aspect(3)

In [14]:gca().apply_aspect()

In [15]:gca().get_position()
Out[15]:
[0.31343312597200623,
  0.099978,
  0.39813374805598761,
  0.80004]

Eric

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users