Re: [Matplotlib-users] forcing a plot to appear

2010-02-16 Thread Matthias Michler
Hi Ken,

On Monday 15 February 2010 20:35:06 Ken Dere wrote:
 Hi,

 I am trying to develop an application that I can run inside the ipython
 shell.  One of my methods creates a plot, asks the user to make a choice
 based on that plot, and then creates another plot that displays the chosen
 set of information.

 If the choices are made with a qt or wx dialogue, everything goes fine.  If
 I try to get the choice by asking the user to type the information into the
 shell, neither plot appears until after the choice is made.

 I have tried show() and draw() but neither make any difference.

I attached a script that allows to input a number via raw_input (after the 
first figure appeared) and than opens up a second figure. I hope the goes 
towards your needs.

Kind regards,
Matthias


let_a_plot_appear.py
Description: application/python
--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] identification of color bars

2010-02-16 Thread Nico Schlömer
Alright, so I dug the sources a bit and found the snippet

== *snip* ==
cb = cbar.Colorbar(cax, mappable, **kw)

def on_changed(m):
#print 'calling on changed', m.get_cmap().name
cb.set_cmap(m.get_cmap())
cb.set_clim(m.get_clim())
cb.update_bruteforce(m)

self.cbid = mappable.callbacksSM.connect('changed', on_changed)
mappable.set_colorbar(cb, cax)
== *snap* ==

I guess what happens is that a Colorbar is created, and a callback
function registered which adapts this very color bar whenever there is
a change in color maps/limits.
Well. -- I reckon that means that at the moment there's no way to tell
if a ScalarMappable has a color bar associated or not. :/ -- At least
I don't see how it would be possible to dig up on_changed( ) from the
list of callbacks and extract cb from it.

Aaand everybody: Fea-ture request, fea-ture request!
get_colorbar() for ScalarMappables :)

Cheers,
Nico




On Mon, Feb 15, 2010 at 7:58 PM, Nico Schlömer nico.schloe...@gmail.com wrote:
 As far as I can see, it is the other way around, i.e., mappables
 (e.g., images) know about the colorbar they are connected.

 Well yeah, that'd be even better. I'll check out the API. -- Hints
 would still be appreciated of course.

 --Nico


--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] DateFormatter + Latex issue

2010-02-16 Thread Ernest Adrogué
15/02/10 @ 19:22 (-0500), thus spake Filipe Pires Alvarenga Fernandes:
 Hello list,
 
 If I use DateFormatter with latex and lines breaks like this
  DateFormatter(\n \n %b) I get an latex error:
 
 http://pastebin.com/m5b186ded
 
 Although, if I do not use the line breaks,
  DateFormatter(%b)
 The problem disappears.
 
 Below is a script that reproduces what I'm talking about:
 
 #Example:
 from pylabimport *
 from matplotlib   import rcParams
 rcParams['text.usetex'] = True
 fig = figure()
 ax  = fig.add_subplot(111)
 fig.subplots_adjust(bottom=0.2)
 t = arange(100,110,.1)
 u = sin(t)
 v = cos(t)
 quiver([t],[[0]*len(t)],u,v)
 major  = DayLocator([10,04])
 minor  = DayLocator()
 majorF = DateFormatter(\n \n %b) # problem
 ^^  ^^
A common mistake.
You forgot to escape the \ characters.

Bye.

Ernest

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] identification of color bars

2010-02-16 Thread Jae-Joon Lee
set_colorbar sets colorbar attribute. So I guess you can just check if
Mappable.colorbar is None or not.
Mappable.colorbar, when set, should be a tuple whose first item is an
image for colorbar and the second item is an colorbar axes.

Regards,

-JJ

On Tue, Feb 16, 2010 at 5:26 AM, Nico Schlömer nico.schloe...@gmail.com wrote:
 Alright, so I dug the sources a bit and found the snippet

 == *snip* ==
        cb = cbar.Colorbar(cax, mappable, **kw)

        def on_changed(m):
            #print 'calling on changed', m.get_cmap().name
            cb.set_cmap(m.get_cmap())
            cb.set_clim(m.get_clim())
            cb.update_bruteforce(m)

        self.cbid = mappable.callbacksSM.connect('changed', on_changed)
        mappable.set_colorbar(cb, cax)
 == *snap* ==

 I guess what happens is that a Colorbar is created, and a callback
 function registered which adapts this very color bar whenever there is
 a change in color maps/limits.
 Well. -- I reckon that means that at the moment there's no way to tell
 if a ScalarMappable has a color bar associated or not. :/ -- At least
 I don't see how it would be possible to dig up on_changed( ) from the
 list of callbacks and extract cb from it.

 Aaand everybody: Fea-ture request, fea-ture request!
 get_colorbar() for ScalarMappables :)

 Cheers,
 Nico




 On Mon, Feb 15, 2010 at 7:58 PM, Nico Schlömer nico.schloe...@gmail.com 
 wrote:
 As far as I can see, it is the other way around, i.e., mappables
 (e.g., images) know about the colorbar they are connected.

 Well yeah, that'd be even better. I'll check out the API. -- Hints
 would still be appreciated of course.

 --Nico



--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] DateFormatter + Latex issue

2010-02-16 Thread Filipe Pires Alvarenga Fernandes
 Thanks Ernest, I had no idea that the DateFormatter was going to be treated
as latex as well.

However, escaping the \ with another \ did not worked.
I tried:

majorF = DateFormatter(\\n \\n %b)

How should I escape the \n ?


 majorF = DateFormatter(\n \n %b) # problem
  ^^  ^^
 A common mistake.
 You forgot to escape the \ characters.

 Bye.

 Ernest

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] identification of color bars

2010-02-16 Thread Nico Schlömer
Works pretty well.
I've now implemented something like

== *snip* ==
def find_associated_colorbar( obj ):
  for child in obj.get_children():
  try:
  cbar = child.colorbar
  except AttributeError:
  continue
  if not cbar == None: # really necessary?
  # if fetch was successful, cbar contains
  # ( reference to colorbar, reference to axis
containing colorbar )
  return cbar[0]
  return None
== *snip* ==

How did you find out about the colormap attribute? Was that by taking
a good guess in looking at the source code, or are the public
attributes of a class documented?

Cheers,
Nico



On Tue, Feb 16, 2010 at 1:18 PM, Jae-Joon Lee lee.j.j...@gmail.com wrote:
 set_colorbar sets colorbar attribute. So I guess you can just check if
 Mappable.colorbar is None or not.
 Mappable.colorbar, when set, should be a tuple whose first item is an
 image for colorbar and the second item is an colorbar axes.

 Regards,

 -JJ

 On Tue, Feb 16, 2010 at 5:26 AM, Nico Schlömer nico.schloe...@gmail.com 
 wrote:
 Alright, so I dug the sources a bit and found the snippet

 == *snip* ==
        cb = cbar.Colorbar(cax, mappable, **kw)

        def on_changed(m):
            #print 'calling on changed', m.get_cmap().name
            cb.set_cmap(m.get_cmap())
            cb.set_clim(m.get_clim())
            cb.update_bruteforce(m)

        self.cbid = mappable.callbacksSM.connect('changed', on_changed)
        mappable.set_colorbar(cb, cax)
 == *snap* ==

 I guess what happens is that a Colorbar is created, and a callback
 function registered which adapts this very color bar whenever there is
 a change in color maps/limits.
 Well. -- I reckon that means that at the moment there's no way to tell
 if a ScalarMappable has a color bar associated or not. :/ -- At least
 I don't see how it would be possible to dig up on_changed( ) from the
 list of callbacks and extract cb from it.

 Aaand everybody: Fea-ture request, fea-ture request!
 get_colorbar() for ScalarMappables :)

 Cheers,
 Nico




 On Mon, Feb 15, 2010 at 7:58 PM, Nico Schlömer nico.schloe...@gmail.com 
 wrote:
 As far as I can see, it is the other way around, i.e., mappables
 (e.g., images) know about the colorbar they are connected.

 Well yeah, that'd be even better. I'll check out the API. -- Hints
 would still be appreciated of course.

 --Nico




--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Enter Figure on Macs

2010-02-16 Thread Michiel de Hoon
Thanks! That was at least part of the problem.
I've committed a bug fix to the svn repository.

Thanks gain,

--Michiel.

--- On Mon, 2/15/10, John Hunter jdh2...@gmail.com wrote:

 From: John Hunter jdh2...@gmail.com
 Subject: Re: [Matplotlib-users] Enter Figure on Macs
 To: Michiel de Hoon mjldeh...@yahoo.com
 Cc: David Arnold dwarnol...@suddenlink.net, 
 matplotlib-users@lists.sourceforge.net
 Date: Monday, February 15, 2010, 8:07 AM
 On Mon, Feb 15, 2010 at 6:50 AM,
 Michiel de Hoon mjldeh...@yahoo.com
 wrote:
  I almost have a solution for this for the Mac OS X
 backend. I am stuck though at what I should pass to
 enter_notify_event and leave_notify_event for the guiEvent:
 
     def leave_notify_event(self, guiEvent=None):
         
         Backend derived classes should call this
 function when leaving
         canvas
 
         *guiEvent*
             the native UI event that generated
 the mpl event
 
         
 
  What are the requirements for guiEvent? If I call
 leave_notify_event without guiEvent, so guiEvent = None,
 then the example gives me the following error:
 
 we don't make any assumptions about what kind of object the
 gui event
 is.  We provide the GUI event because sometimes when
 using a specific
 backend, the user wants to drill into the GUI native event
 (eg a
 button press event) but we don't use it anywhere in the mpl
 frontend
 because this would break the abstraction.  So if you
 have some event
 that is being fired at the UI level on figure enter, pass
 that in.
 
 It looks like you may be having a problem because the
 leave_notify_event is getting called more than once, or is
 called for
 a figure that has not been entered.  Check the logic
 in
 backend_bases.FigureCanvasBase.leave_notify_event
 
 
     def leave_notify_event(self, guiEvent=None):
         
         Backend derived classes should
 call this function when leaving
         canvas
 
         *guiEvent*
             the native UI
 event that generated the mpl event
 
         
        
 self.callbacks.process('figure_leave_event',
 LocationEvent.lastevent)
         LocationEvent.lastevent = None
 
 
 It looks like your figure_leave_event is being triggered
 with
 LocationEvent.lastevent = None (so it is not a problem with
 your
 guiEvent).  This could happen if a leave event was
 processed *before*
 and enter event (which sets the lastevent), or if a leave
 event was
 processed twice.
 
 Hopefully this will help you drill down into the source of
 the problem
 
 JDH
 


  

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] agg_buffer_to_array.py

2010-02-16 Thread Michiel de Hoon
Hi David,

The Mac OS X backend does not use Agg, so I am not surprised that this script 
won't work with Mac OS X backend. The script probably also won't work with 
other non-Agg backends such as GtkCairo.

--Michiel.

--- On Mon, 2/15/10, David Arnold dwarnol...@suddenlink.net wrote:

 From: David Arnold dwarnol...@suddenlink.net
 Subject: [Matplotlib-users] agg_buffer_to_array.py
 To: matplotlib-users@lists.sourceforge.net
 Date: Monday, February 15, 2010, 2:12 PM
 All,
 This error:The
 debugged program raised the exception unhandled AttributeError
 'FigureCanvasMac' object
 has no attribute 'buffer_rgba'
 File: 
 /Users/darnold/Documents/temp/Matplotlib/PylabExamples/agg_buffer_to_array.py,
 Line: 16is raised
 by the following script on my Macbook.
 #
 agg_buffer_to_array.py import
 matplotlibmatplotlib.use('macosx')from
 pylab import figure, showimport numpy as
 np
 # make an agg figurefig =
 figure()ax =
 fig.add_subplot(111)ax.plot([1,2,3])ax.set_title('a
 simple figure')fig.canvas.draw()
 # grab rhe pixel buffer and dumpy it into a
 numpy arraybuf =
 fig.canvas.buffer_rgba(0,0)l, b, w, h =
 fig.bbox.boundsX = np.fromstring(buf,
 np.uint8)X.shape = h,w,4
 # now display the array X as an Axes in a new
 figurefig2 = figure()ax2 =
 fig2.add_subplot(111,
 frameon=False)ax2.imshow(X)show()
 This is captured from:  
 http://matplotlib.sourceforge.net/examples/pylab_examples/agg_buffer_to_array.html
 With:
 matplotlib.use('Agg')
 Nothing happens at all. With --verbose-helpful,
 yields the following:
 $HOME=/Users/darnoldCONFIGDIR=/Users/darnold/.matplotlibmatplotlib
 data path
 /Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/matplotlib/mpl-dataloaded
 rc file
 /Users/darnold/.matplotlib/matplotlibrcmatplotlib
 version 0.99.1.1verbose.level
 helpfulinteractive is Falseunits is
 Falseplatform is darwinUsing
 fontManager instance from
 /Users/darnold/.matplotlib/fontList.cachebackend
 agg version v2.2findfont: Matching
 :family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=medium
 to Bitstream Vera Sans
 (/Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib-0.98.5.2n2-py2.5-macosx-10.3-fat.egg/matplotlib/mpl-data/fonts/ttf/Vera.ttf)
 with score of 0.00findfont: Matching
 :family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=large
 to Bitstream Vera Sans
 (/Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib-0.98.5.2n2-py2.5-macosx-10.3-fat.egg/matplotlib/mpl-data/fonts/ttf/Vera.ttf)
 with score of 0.00
 Both
 matplotlib.use('tkagg')
 and
 matplotlib.use('wxagg')
 work as they should.
 David.
 -Inline Attachment Follows-
 
 --
 SOLARIS 10 is the OS for Data Centers - provides features
 such as DTrace,
 Predictive Self Healing and Award Winning ZFS. Get Solaris
 10 NOW
 http://p.sf.net/sfu/solaris-dev2dev
 -Inline Attachment Follows-
 
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 


  

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] identification of color bars

2010-02-16 Thread Jae-Joon Lee
The last line of the on_changed method you posted is

   mappable.set_colorbar(cb, cax)

And set_colorbar sets the colorbar attribute.

-JJ

On Tue, Feb 16, 2010 at 8:46 AM, Nico Schlömer nico.schloe...@gmail.com wrote:
 Works pretty well.
 I've now implemented something like

 == *snip* ==
 def find_associated_colorbar( obj ):
      for child in obj.get_children():
              try:
                      cbar = child.colorbar
              except AttributeError:
                      continue
              if not cbar == None: # really necessary?
                      # if fetch was successful, cbar contains
                      # ( reference to colorbar, reference to axis
 containing colorbar )
                      return cbar[0]
      return None
 == *snip* ==

 How did you find out about the colormap attribute? Was that by taking
 a good guess in looking at the source code, or are the public
 attributes of a class documented?

 Cheers,
 Nico



 On Tue, Feb 16, 2010 at 1:18 PM, Jae-Joon Lee lee.j.j...@gmail.com wrote:
 set_colorbar sets colorbar attribute. So I guess you can just check if
 Mappable.colorbar is None or not.
 Mappable.colorbar, when set, should be a tuple whose first item is an
 image for colorbar and the second item is an colorbar axes.

 Regards,

 -JJ

 On Tue, Feb 16, 2010 at 5:26 AM, Nico Schlömer nico.schloe...@gmail.com 
 wrote:
 Alright, so I dug the sources a bit and found the snippet

 == *snip* ==
        cb = cbar.Colorbar(cax, mappable, **kw)

        def on_changed(m):
            #print 'calling on changed', m.get_cmap().name
            cb.set_cmap(m.get_cmap())
            cb.set_clim(m.get_clim())
            cb.update_bruteforce(m)

        self.cbid = mappable.callbacksSM.connect('changed', on_changed)
        mappable.set_colorbar(cb, cax)
 == *snap* ==

 I guess what happens is that a Colorbar is created, and a callback
 function registered which adapts this very color bar whenever there is
 a change in color maps/limits.
 Well. -- I reckon that means that at the moment there's no way to tell
 if a ScalarMappable has a color bar associated or not. :/ -- At least
 I don't see how it would be possible to dig up on_changed( ) from the
 list of callbacks and extract cb from it.

 Aaand everybody: Fea-ture request, fea-ture request!
 get_colorbar() for ScalarMappables :)

 Cheers,
 Nico




 On Mon, Feb 15, 2010 at 7:58 PM, Nico Schlömer nico.schloe...@gmail.com 
 wrote:
 As far as I can see, it is the other way around, i.e., mappables
 (e.g., images) know about the colorbar they are connected.

 Well yeah, that'd be even better. I'll check out the API. -- Hints
 would still be appreciated of course.

 --Nico





--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] TikZ/PGF backend

2010-02-16 Thread Nico Schlömer
Well, I spend some time now setting up a framework for exporting
matplotlib generated figures to TikZ code.
You can find it on

   http://github.com/nicki/matplotlib2tikz

The workflow is essentially that you generate your plot (dont show()),
and then call matplotlib2tikz(myfile.tikz); using a proper back-end
has been considered not useful (b/c the information that the back-ends
can access purely contain geometric information, and not semantic info
such as this color bar belongs to plot such-and-such).

What the script can do now, essentially, is line plots, images, color
bars. Adding more functionality should not be too difficult and is
basically just a matter of actually doing it. If you're interested in
helping out then I'd think now is the time as the script is a mere 350
lines long now; just poke me on github.

Cheers,
Nico

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Trouble gridding irregularly spaced data

2010-02-16 Thread Robert Kern
On 2010-02-16 00:40 AM, T J wrote:
 Hi,

 I'm trying to grid irregularly spaced data, such that the convex hull
 of the data is not rectangular.  Specifically, all my data lies in an
 equilateral triangle inside the unit circle.  I found:

   
 http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data

 and tried the suggested technique.  For my grid, I made a square of
 the min and max of my data.  However, it had problems:

 ...
File 
 /home/guest/.local/lib/python2.6/site-packages/matplotlib/delaunay/triangulate.py,
 line 125, in _compute_convex_hull
  hull.append(edges.pop(hull[-1]))
 KeyError: 0


 Should I expect matplotlib.mlab.griddata to work with a dataset like
 this?  I know that I can use hexbin, but it'd be really nice to see
 contours explicitly.

It's not a problem with your points lying inside a triangle. There is some 
other 
problem with the construction of the Delaunay triangulation. Sometimes the 
algorithm fails. This is one way that it fails.

-- 
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth.
   -- Umberto Eco


--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] can't update transform for polygon animation

2010-02-16 Thread John Jameson
Hi John,

Thanks for your help on the animation with patches, and now
I'm trying to do the same idea for matplotlib.patches.Polygon 
ala your method for a circle patch:

initialize:
xy =[[x0,y0],[x1,y1],[x2,y2]]
  poly = Polygon( xy, animated=True,lw=2,fill=False )
add_patch(poly)
.
.
in the loop:
poly.set_xy = xy_new
poly.update_transorm()  (no such routine)   

  
The set_xy seems to work (at least no errors), but I don't see how 
to update the transform as for the circle.

here I am looking at:
http://matplotlib.sourceforge.net/api/artist_api.html?highlight=polygon#matp
lotlib.patches.Polygon 

thanks,
john





-Original Message-
From: John Hunter [mailto:jdh2...@gmail.com] 
Sent: Sunday, February 14, 2010 7:39 PM
To: John Jameson
Cc: matplotlib-users@lists.sourceforge.net; Michael Droettboom
Subject: Re: [Matplotlib-users] memory leak for GTKAgg animation

On Sat, Feb 13, 2010 at 2:53 PM, John Jameson jjame...@altoresearch.com
wrote:
 HI,
 I find the very basic animation below has a memory leak (my pagefile usage
 number keeps growing in the Windows XP Windows Task Manager Performance
 graph).I don't see this with the animation_blit_gtk.py example on:

 http://matplotlib.sourceforge.net/examples/index.html

 (which I used as a starting point for this). In animation_blit_gtk.py
the
 set_ydata() routine is used to update the line for the animation and this
 does not leak. But if you call plot again with the new y_data (instead of
 using set_ydata), this leaks too. Anyone have an idea on how to stop the
 leak?

This isn't a memory leak.  The problem is that you keep adding new
patches to the axes when you want just one with different data.  Eg,
in your loop, run this code, and you will see that the number of
patches is growing:


   x_cir = 1.0 + 0.003*update_line.cnt
   cir =  CirclePolygon((x_cir, 1), 0.3, animated=True, \
   resolution=12, lw=2 )
   ax.add_patch(cir)
   ax.draw_artist(cir)
   print 'num patches=%d, mem usage=%d'%(
   len(ax.patches), cbook.report_memory(update_line.cnt))
   canvas.blit(ax.bbox)

You should add just one patch and then manipulate the data.  In this
case, you are using a CirclePolygon which derives from RegularPolygon
and so you can update the xy property

 
http://matplotlib.sourceforge.net/api/artist_api.html#matplotlib.patches.Reg
ularPolygon

But on testing this it looks like there is a bug in that the set_xy
property setter is ignored.  I worked around this in the func below by
setting the private variable directly, but this looks like a bug we
need to fix (Michael, shouldn't we respect the xy passed in in
patches.RegularPolygon._set_xy ?).  In the meantime, the following
workaround should work for you w/o leaking

def update_line():
   global x, y
   print update_line.cnt
   if update_line.background is None:
   update_line.background = canvas.copy_from_bbox(ax.bbox)
   canvas.restore_region(update_line.background)

   x_cir = 1.0 + 0.003*update_line.cnt

   if update_line.cir is None:
   cir =  CirclePolygon((x_cir, 1), 0.3, animated=True, \
   resolution=12, lw=2 )
   ax.add_patch(cir)
   update_line.cir = cir
   else:
   update_line.cir._xy = x_cir, 1
   update_line.cir._update_transform()
   ax.draw_artist(update_line.cir)
   print 'num patches=%d, xy=%s, mem usage=%d'%(
   len(ax.patches), update_line.cir.xy,
cbook.report_memory(update_line.cnt))
   canvas.blit(ax.bbox)

   if update_line.direction == 0:
   update_line.cnt += 1
   if update_line.cnt  500:
   update_line.direction = 1
   else:
   update_line.cnt -= 1
   if update_line.cnt  100:
   update_line.direction = 0

   return update_line.cnt100


update_line.cnt = 0
update_line.direction = 0
update_line.background = None
update_line.cir = None



--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Trouble gridding irregularly spaced data

2010-02-16 Thread Jeff Whitaker
T J wrote:
 Hi,

 I'm trying to grid irregularly spaced data, such that the convex hull
 of the data is not rectangular.  Specifically, all my data lies in an
 equilateral triangle inside the unit circle.  I found:

  http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data

 and tried the suggested technique.  For my grid, I made a square of
 the min and max of my data.  However, it had problems:

 ...
   File 
 /home/guest/.local/lib/python2.6/site-packages/matplotlib/delaunay/triangulate.py,
 line 125, in _compute_convex_hull
 hull.append(edges.pop(hull[-1]))
 KeyError: 0


 Should I expect matplotlib.mlab.griddata to work with a dataset like
 this?  I know that I can use hexbin, but it'd be really nice to see
 contours explicitly.
   

We have the natgrid toolkit for just this reason - it's slower than the 
default, and has a more restrictive license, but it often succeeds when 
the default algorithm fails.  This is discussed at the end of that wiki 
page.  Let us know if the natgrid toolkit also fails.

-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


--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to blank an area of the canvas?

2010-02-16 Thread Brendan Barnwell
Jae-Joon Lee wrote:
 I have added a bbox support for restore_region, but I'm afraid
 that this feature is not well tested. And I guess what you find
 is, unfortunately,  a bug. While I'll try to push the changes to
 the svn tomorrow, you may try to monkey-patch with following
 code.
snip

Thanks a lot, this seems to basically work.  For some reason the
bboxes are still restored at slightly the wrong place --- I have to
adjust them by one pixel in the y direction, but this is doable.

 However, while matplotlib does support some animation, I think
 you 'd better turn to another tool if you need an efficiency,

Maybe so.  What tool would you recommend for animated plots?

Best wishes,
-- Brendan Barnwell Do not follow where the path may lead. Go,
instead, where there is no path, and leave a trail. --author unknown

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] add to a canvas while preserving overall formatting

2010-02-16 Thread C M
I have a mpl graph embedded in wxPython, and I call a function,
customize_plot() to do a number of things to the plot:  adjust the
spacing around it, set the formatters, fontsizes, axis limits, set a
grid, etc.

Now I want to potentially highlight points (by adding semi-transparent
points on top of existing ones) or annotate points with user
interaction.  If I do that, it seems I need to call canvas.draw().
But when I do that, it redraws the whole canvas and ignores some of
the formatting I laid out in customize_plot(), specifically the view
limits, and that's not acceptable.

I want it to simply add the new points without changing any of the
features of the plot.  Is there a way to do that?  In Googling for
hints, I found this point from JDH from almost two years ago, which I
think is applicable to my need:

 If you call fig.canvas.draw, everything will be updated.  If you want
 to selectively draw certain artists, you can use the animated property
 w/ background copy/restore and the draw_artist method as described at

 http://www.scipy.org/Cookbook/Matplotlib/Animations

Is this still the case in the current version of matplotlib?  Or is
there a newer way to do it now?

Thank you for any suggestions,
Che

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] can't update transform for polygon animation

2010-02-16 Thread John Hunter
On Tue, Feb 16, 2010 at 10:54 AM, John Jameson
jjame...@altoresearch.com wrote:
 Hi John,

 Thanks for your help on the animation with patches, and now
 I'm trying to do the same idea for matplotlib.patches.Polygon
 ala your method for a circle patch:

    initialize:
        xy =[[x0,y0],[x1,y1],[x2,y2]]
      poly = Polygon( xy, animated=True,lw=2,fill=False )
        add_patch(poly)
                                .
                                .
    in the loop:
        poly.set_xy = xy_new
        poly.update_transorm()  (no such routine)


 The set_xy seems to work (at least no errors), but I don't see how
 to update the transform as for the circle.

Two problems here :

* There is no polygon attribute set_xy; it is a method, so you need
to call it like poly.set_xy(xy_new).  In general this is True for
all matplotlib set_* methods.  There is also an xy attribute which
you can access like poly.xy = xy_new.  These two approaches do the
same thing

* The _update_transforms call was a hack I did on CirclePolygon to
work around a broken method.  it is not a method of Polygon or Patch
which is why you are not finding it.  For normal usage, the methods
that start with underscores are not meant to be called or used at the
user level, but because there was breakage in the CirclePolygon set_xy
method, I had to hack around it in the example I posted for you.  For
Polygon, simply setting the xy attribute should be sufficient.

JDH

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] add to a canvas while preserving overall formatting

2010-02-16 Thread John Hunter
On Tue, Feb 16, 2010 at 11:14 AM, C M cmpyt...@gmail.com wrote:
 I have a mpl graph embedded in wxPython, and I call a function,
 customize_plot() to do a number of things to the plot:  adjust the
 spacing around it, set the formatters, fontsizes, axis limits, set a
 grid, etc.

 Now I want to potentially highlight points (by adding semi-transparent
 points on top of existing ones) or annotate points with user
 interaction.  If I do that, it seems I need to call canvas.draw().
 But when I do that, it redraws the whole canvas and ignores some of
 the formatting I laid out in customize_plot(), specifically the view
 limits, and that's not acceptable.

This isn't accurate -- calling draw will not change the view limits.
In all likelihood what is happening is that when you add you your
overlay markers, eg by calling plot the view limits are getting
updated.  You can suppress this with

ax.set_autoscale_on(False)
ax.plot(overlay_markers)
fig.canvas.draw()


 I want it to simply add the new points without changing any of the
 features of the plot.  Is there a way to do that?  In Googling for
 hints, I found this point from JDH from almost two years ago, which I
 think is applicable to my need:

 If you call fig.canvas.draw, everything will be updated.  If you want
 to selectively draw certain artists, you can use the animated property
 w/ background copy/restore and the draw_artist method as described at

 http://www.scipy.org/Cookbook/Matplotlib/Animations

 Is this still the case in the current version of matplotlib?  Or is
 there a newer way to do it now?

Yes, this is still accurate, and can be use for more efficient
updating, but it is unrelated to the problem with the view limits you
described.

JDH

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Suggestion for filtering by calendar?

2010-02-16 Thread David Carmean

I have a time-series dataset for which I need to make several plots; 
some of them will use all of the data, but others need not only to 
show just the usual business hours, but also take business holidays 
into account.  I thoght this might be sufficiently common in this 
community that somebody could easily point me to a python idiom/recipe 
they've used that I could extend to use masked arrays.

FWIW, the idea is not that I want to skip those time periods on the 
visualizations--and thus the recipes which treat the data as 
non-timeseries and construct custom ticks are not the solution for me.
One of the tasks will be to use a fill to shade in these working hours 
for some of the plots.  Another will be to calculate and plot running 
averages that exclude non-working hours.

Thanks.



--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] add to a canvas while preserving overall formatting

2010-02-16 Thread C M
On Tue, Feb 16, 2010 at 12:37 PM, John Hunter jdh2...@gmail.com wrote:
 On Tue, Feb 16, 2010 at 11:14 AM, C M cmpyt...@gmail.com wrote:
 I have a mpl graph embedded in wxPython, and I call a function,
 customize_plot() to do a number of things to the plot:  adjust the
 spacing around it, set the formatters, fontsizes, axis limits, set a
 grid, etc.

 Now I want to potentially highlight points (by adding semi-transparent
 points on top of existing ones) or annotate points with user
 interaction.  If I do that, it seems I need to call canvas.draw().
 But when I do that, it redraws the whole canvas and ignores some of
 the formatting I laid out in customize_plot(), specifically the view
 limits, and that's not acceptable.

 This isn't accurate -- calling draw will not change the view limits.
 In all likelihood what is happening is that when you add you your
 overlay markers, eg by calling plot the view limits are getting
 updated.  You can suppress this with

 ax.set_autoscale_on(False)
 ax.plot(overlay_markers)
 fig.canvas.draw()

Thank you, that's much easier than the animation option, which would
be more than I need to do.

Che

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Color in table help please! I have already searched previous posts

2010-02-16 Thread duckman

I am trying to make the table at the bottom and the lines the same color.  I
took the code from one of the online examples and modified it to do most of
what I want but cannot get the color in the table working properly! Can
someone please help?  Thank you

#!/usr/bin/env python
import matplotlib
from pylab import *
from matplotlib.colors import colorConverter

color3=(1,0,0)
axes([0.2, 0.2, 0.7, 0.6])   # leave room below the axes for the table

data = [[
100.00,349.75,171.44,625.53,134635.8,248978.4,160392.1,179662.4,123550.5],
[
235998.8,99972.15,242081.6,84912.13,243705.3,247201.2,203676.4,90139.60,113332.5],
[
202610.0,127785.3,182007.1,175678.0,154024.1,188675.2,166227.0,94719.93,160227.7],
[
31699.09,30586.87,30587.58,33440.05,32209.72,34223.97,28250.25,32070.29,19095.30],
[
84414.35,21884.88,49538.22,49200.55,42394.29,66676.73,57740.81,73549.68,48402.48],
[ 0.0,0.0,0.0,0.0,023529.88,19822.02,35243.35,34349.67,19382.45]]

title('Title')
colLabels = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep')
rowLabels = ['Dr %d' % x for x in (1, 2, 3, 7, 8, 10)]

linecolor = ('blue','red','green','black','yellow','cyan','magenta')

rows = len(data)

ind = arange(len(colLabels))  # the x locations for the groups
cellText = []
yoff = array([0.0] * len(colLabels)) # the bottom values for stacked bar
chart
for row in xrange(rows):
plot(arange(0,9), data[row],color=linecolor[row])
yoff = data[row]
cellText.append(['%1.2f' % (x) for x in yoff])
# Add a table at the bottom of the axes

#title([color3])
the_table = table(cellText=cellText,
  rowLabels=rowLabels, rowColours=[color3]*16,
  colLabels=colLabels,
  loc='bottom')
vals = arange(0, 35, 25000)
yticks(vals, ['%d' % val for val in vals])
xticks([])
savefig(tony.png,dpi=(1024/8))

-- 
View this message in context: 
http://old.nabble.com/Color-in-table-help-please%21--I-have-already-searched-previous-posts-tp27613553p27613553.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] DateFormatter + Latex issue

2010-02-16 Thread Ernest Adrogué
16/02/10 @ 09:03 (-0500), thus spake Filipe Pires Alvarenga Fernandes:
  Thanks Ernest, I had no idea that the DateFormatter was going to be treated
 as latex as well.

Yes, all strings are processed by LaTeX.

 
 However, escaping the \ with another \ did not worked.
 I tried:
 
 majorF = DateFormatter(\\n \\n %b)
 
 How should I escape the \n ?

In theory, \\n \\n %b or r\n \n %b, however only the former
seems to work in my computer.

There's another problem: \n is not a valid LaTeX command.
I tried with \\ and with \newline but neither appear to work. 
\vspace{10pts} does insert whitespace, however I am not sure if
it's the proper way of doing it...

Bye.

 
  majorF = DateFormatter(\n \n %b) # problem
   ^^  ^^
  A common mistake.
  You forgot to escape the \ characters.
 
  Bye.
 
  Ernest
 

 --
 SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
 Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
 http://p.sf.net/sfu/solaris-dev2dev

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


--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Where Do I Report MPL Guide Issues?

2010-02-16 Thread Wayne Watson
Good. Thanks. Did I do the right thing by posting here? Is it the case 
that all parts of the document are contributions?

On 2/15/2010 11:02 PM, Philipp Bender wrote:
 When I come back tonight I will try to fix the errors for you.

 --
 SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
 Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
 http://p.sf.net/sfu/solaris-dev2dev
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users



-- 
 There is nothing so annoying as to have two people
  talking when you're busy interrupting. -- Mark Twain


--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] DateFormatter + Latex issue

2010-02-16 Thread Filipe Pires Alvarenga Fernandes
\\  works for titles and label, but not for DateFormatter, but \vspace did
the trick!

Thanks again for the help.

ps: I'm new to python, but maybe there is a way to mix Latex and unicode?


 as latex as well.

 Yes, all strings are processed by LaTeX.

 
  However, escaping the \ with another \ did not worked.
  I tried:
 
  majorF = DateFormatter(\\n \\n %b)
 
  How should I escape the \n ?

 In theory, \\n \\n %b or r\n \n %b, however only the former
 seems to work in my computer.

 There's another problem: \n is not a valid LaTeX command.
 I tried with \\ and with \newline but neither appear to work.
 \vspace{10pts} does insert whitespace, however I am not sure if
 it's the proper way of doing it...

 Bye.

 
   majorF = DateFormatter(\n \n %b) # problem
^^  ^^
   A common mistake.
   You forgot to escape the \ characters.
  
   Bye.
  
   Ernest

  Thanks Ernest, I had no idea that the DateFormatter was going to be
treated
--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] forcing a plot to appear

2010-02-16 Thread Ken Dere
Matthias Michler wrote:

 Hi Ken,
 
 On Monday 15 February 2010 20:35:06 Ken Dere wrote:
 Hi,

 I am trying to develop an application that I can run inside the ipython
 shell.  One of my methods creates a plot, asks the user to make a choice
 based on that plot, and then creates another plot that displays the
 chosen set of information.

 If the choices are made with a qt or wx dialogue, everything goes fine. 
 If I try to get the choice by asking the user to type the information
 into the shell, neither plot appears until after the choice is made.

 I have tried show() and draw() but neither make any difference.
 
 I attached a script that allows to input a number via raw_input (after
 the first figure appeared) and than opens up a second figure. I hope the
 goes towards your needs.
 
 Kind regards,
 Matthias

That did the trick.  I think it was problably the use of .ion() and .ioff() 
that did it but I just did the whole fix and didn't check to see what was 
what.

many thanks!


-- 
K. Dere


--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] DateFormatter + Latex issue

2010-02-16 Thread Ernest Adrogué
16/02/10 @ 16:20 (-0500), thus spake Filipe Pires Alvarenga Fernandes:
 \\  works for titles and label, but not for DateFormatter, but \vspace did
 the trick!
 
 Thanks again for the help.
 
 ps: I'm new to python, but maybe there is a way to mix Latex and unicode?

Yes, the inputenc package from latex lets you use unicode.
Try adding this to your script:
plt.rc('text.latex', preamble='\usepackage[utf]{inputenc}')

Note that this setting is not officially supported, whatever
that means :)

I also like the txfonts package:
\usepackage[varg]{txfonts}

which changes the default font to Times, including the text in
mathematical expressions. It looks great.

Cheers.

Ernest

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] DateFormatter + Latex issue

2010-02-16 Thread Jae-Joon Lee
On Tue, Feb 16, 2010 at 4:05 PM, Ernest Adrogué eadro...@gmx.net wrote:
 \vspace{10pts} does insert whitespace, however I am not sure if
 it's the proper way of doing it...


Can you (or someone else) confirm this? I don't think pts is a
proper tex unit and it should be \vspace{10pt}. Maybe this is a typo
in the email. I'm asking this because it does not work for me, and I
don't think it is supposed to work (but I may be wrong).

Regards,

-JJ

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] DateFormatter + Latex issue

2010-02-16 Thread PHobson
 -Original Message-
 From: Ernest Adrogué [mailto:eadro...@gmx.net]
 Sent: Tuesday, February 16, 2010 1:58 PM
 To: matplotlib-users@lists.sourceforge.net
 Subject: Re: [Matplotlib-users] DateFormatter + Latex issue
 
 16/02/10 @ 16:20 (-0500), thus spake Filipe Pires Alvarenga Fernandes:
  \\  works for titles and label, but not for DateFormatter, but
 \vspace did
  the trick!
 
  Thanks again for the help.
 
  ps: I'm new to python, but maybe there is a way to mix Latex and
 unicode?
 
 Yes, the inputenc package from latex lets you use unicode.
 Try adding this to your script:
 plt.rc('text.latex', preamble='\usepackage[utf]{inputenc}')
 
 Note that this setting is not officially supported, whatever
 that means :)
 
 I also like the txfonts package:
 \usepackage[varg]{txfonts}
 
 which changes the default font to Times, including the text in
 mathematical expressions. It looks great.

Good tip. I also like \usapackage{fourier} to get the utopia fonts, which are 
particularly useful since I'm always plotting concentrations and having a 
upright mu ($\othermu$) is really nice.

-paul h.

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] DateFormatter + Latex issue

2010-02-16 Thread Jae-Joon Lee
If what you want is to have more padding for the major tick labels, I
recommend you to use

rcParams['xtick.major.pad'] = 20

If you don't like to change the global setting, you may set the
ticklabel padding for an specific axis. Try

for tck in ax.xaxis.get_major_ticks():
tck.set_pad(20)
tck.label1 = tck._get_text1()

Regards,

-JJ


On Tue, Feb 16, 2010 at 4:20 PM, Filipe Pires Alvarenga Fernandes
ocef...@gmail.com wrote:
 \\  works for titles and label, but not for DateFormatter, but \vspace did
 the trick!

 Thanks again for the help.

 ps: I'm new to python, but maybe there is a way to mix Latex and unicode?


  as latex as well.

 Yes, all strings are processed by LaTeX.

 
  However, escaping the \ with another \ did not worked.
  I tried:
 
  majorF = DateFormatter(\\n \\n %b)
 
  How should I escape the \n ?

 In theory, \\n \\n %b or r\n \n %b, however only the former
 seems to work in my computer.

 There's another problem: \n is not a valid LaTeX command.
 I tried with \\ and with \newline but neither appear to work.
 \vspace{10pts} does insert whitespace, however I am not sure if
 it's the proper way of doing it...

 Bye.

 
   majorF = DateFormatter(\n \n %b) # problem
                            ^^  ^^
   A common mistake.
   You forgot to escape the \ characters.
  
   Bye.
  
   Ernest

  Thanks Ernest, I had no idea that the DateFormatter was going to be
 treated

 --
 SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
 Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
 http://p.sf.net/sfu/solaris-dev2dev
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users



--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] howto save MplWidget to png or tif file --- savefig not working

2010-02-16 Thread Dave M Tung
HI folks,

   anybody know how to save a canvas (MplWidget)  to a png or tif file.
 Seems
   when I try to save the figure,

   whichCanvas.canvas.ax.plot(xSlice, ySlice, 'bo', linewidth=1.5,
linestyle='-')

   savefig does not work for this type of object.  Is there another method I
   should use that I
   missed?
   thanks
   dave
    MplWidget
   Classs 
   from PyQt4 import QtGui

- Ignored:
   from matplotlib.backends.backend_qt4agg \
   import FigureCanvasQTAgg as FigureCanvas
   from matplotlib.figure import Figure




   class MplCanvas(FigureCanvas):
   def __init__(self):
   self.fig = Figure()
   self.ax = self.fig.add_subplot(111)
   FigureCanvas.__init__(self, self.fig)
   FigureCanvas.setSizePolicy(self,
   QtGui.QSizePolicy.Expanding,
   QtGui.QSizePolicy.Expanding)
   FigureCanvas.updateGeometry(self)




   class MplWidget(QtGui.QWidget):

   def __init__(self, parent = None):
   QtGui.QWidget.__init__(self, parent)
   self.canvas = MplCanvas()
   self.vbl = QtGui.QVBoxLayout()
   self.vbl.addWidget(self.canvas)
   self.setLayout(self.vbl)


On Tue, Feb 16, 2010 at 1:57 PM, 
matplotlib-users-requ...@lists.sourceforge.net wrote:

 Send Matplotlib-users mailing list submissions to
matplotlib-users@lists.sourceforge.net

 To subscribe or unsubscribe via the World Wide Web, visit
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 or, via email, send a message with subject or body 'help' to
matplotlib-users-requ...@lists.sourceforge.net

 You can reach the person managing the list at
matplotlib-users-ow...@lists.sourceforge.net

 When replying, please edit your Subject line so it is more specific
 than Re: Contents of Matplotlib-users digest...


 Today's Topics:

   1. Suggestion for filtering by calendar? (David Carmean)
   2. Re: add to a canvas while preserving overall  formatting (C M)
   3. Color in table help please! I have already searched previous
  posts (duckman)
   4. Re: DateFormatter + Latex issue (Ernest Adrogu?)
   5. Re: Where Do I Report MPL Guide Issues? (Wayne Watson)
   6. Re: DateFormatter + Latex issue (Filipe Pires Alvarenga Fernandes)
   7. Re: forcing a plot to appear (Ken Dere)
   8. Re: DateFormatter + Latex issue (Ernest Adrogu?)


 --

 Message: 1
 Date: Tue, 16 Feb 2010 09:51:47 -0800
 From: David Carmean d...@halibut.com
 Subject: [Matplotlib-users] Suggestion for filtering by calendar?
 To: matplotlib-users@lists.sourceforge.net
 Message-ID: 20100216095147.k26...@halibut.com
 Content-Type: text/plain; charset=us-ascii


 I have a time-series dataset for which I need to make several plots;
 some of them will use all of the data, but others need not only to
 show just the usual business hours, but also take business holidays
 into account.  I thoght this might be sufficiently common in this
 community that somebody could easily point me to a python idiom/recipe
 they've used that I could extend to use masked arrays.

 FWIW, the idea is not that I want to skip those time periods on the
 visualizations--and thus the recipes which treat the data as
 non-timeseries and construct custom ticks are not the solution for me.
 One of the tasks will be to use a fill to shade in these working hours
 for some of the plots.  Another will be to calculate and plot running
 averages that exclude non-working hours.

 Thanks.





 --

 Message: 2
 Date: Tue, 16 Feb 2010 14:07:04 -0500
 From: C M cmpyt...@gmail.com
 Subject: Re: [Matplotlib-users] add to a canvas while preserving
overall formatting
 To: Matplotlib Users matplotlib-users@lists.sourceforge.net
 Message-ID:
cc8074371002161107w6ef0f865wdece7d0a74c61...@mail.gmail.com
 Content-Type: text/plain; charset=ISO-8859-1

 On Tue, Feb 16, 2010 at 12:37 PM, John Hunter jdh2...@gmail.com wrote:
  On Tue, Feb 16, 2010 at 11:14 AM, C M cmpyt...@gmail.com wrote:
  I have a mpl graph embedded in wxPython, and I call a function,
  customize_plot() to do a number of things to the plot: ?adjust the
  spacing around it, set the formatters, fontsizes, axis limits, set a
  grid, etc.
 
  Now I want to potentially highlight points (by adding semi-transparent
  points on top of existing ones) or annotate points with user
  interaction. ?If I do that, it seems I need to call canvas.draw().
  But when I do that, it redraws the whole canvas and ignores some of
  the formatting I laid out in customize_plot(), specifically the view
  limits, and that's not acceptable.
 
  This isn't accurate -- calling draw will not change the view limits.
  In all likelihood what is happening is that when you add you your
  overlay markers, eg by calling plot the view limits 

Re: [Matplotlib-users] DateFormatter + Latex issue

2010-02-16 Thread Ernest Adrogué
Hi,

16/02/10 @ 17:01 (-0500), thus spake Jae-Joon Lee:
 On Tue, Feb 16, 2010 at 4:05 PM, Ernest Adrogué eadro...@gmx.net wrote:
  \vspace{10pts} does insert whitespace, however I am not sure if
  it's the proper way of doing it...
 
 
 Can you (or someone else) confirm this? I don't think pts is a
 proper tex unit and it should be \vspace{10pt}. Maybe this is a typo
 in the email. I'm asking this because it does not work for me, and I
 don't think it is supposed to work (but I may be wrong).

You're right!
\vspace{10pts} adds space (seems about 10 points) but it also
prints a s before the space, which I didn't see before.
Now, \vspace{10pt} doesn't work for me... it simply does nothing.

Bye.

 Regards,
 
 -JJ

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] DateFormatter + Latex issue

2010-02-16 Thread Filipe Pires Alvarenga Fernandes
JJ:
Wonderful, simple  and much less messy and Latex+unicode. Although, now I'm
fascinated by the Latex possibilities!

Ernest:
 I haven't notice the s before when using pts, but what is really
strange is that pt does not work!


Thank you all again, Filipe
--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] howto save MplWidget to png or tif file --- savefig not working

2010-02-16 Thread John Hunter
On Tue, Feb 16, 2010 at 4:07 PM, Dave M Tung dave.m.t...@seagate.com wrote:

 HI folks,

    anybody know how to save a canvas (MplWidget)  to a png or tif file.
  Seems
    when I try to save the figure,

    whichCanvas.canvas.ax.plot(xSlice, ySlice, 'bo', linewidth=1.5,
 linestyle='-')

    savefig does not work for this type of object.  Is there another method I
    should use that I
    missed?
    thanks
    dave
     MplWidget
    Classs 
    from PyQt4 import QtGui

 - Ignored:
    from matplotlib.backends.backend_qt4agg \
            import FigureCanvasQTAgg as FigureCanvas
    from matplotlib.figure import Figure




    class MplCanvas(FigureCanvas):
        def __init__(self):
            self.fig = Figure()
            self.ax = self.fig.add_subplot(111)
            FigureCanvas.__init__(self, self.fig)
            FigureCanvas.setSizePolicy(self,
                QtGui.QSizePolicy.Expanding,
                QtGui.QSizePolicy.Expanding)
            FigureCanvas.updateGeometry(self)




    class MplWidget(QtGui.QWidget):

        def __init__(self, parent = None):
            QtGui.QWidget.__init__(self, parent)
            self.canvas = MplCanvas()
            self.vbl = QtGui.QVBoxLayout()
            self.vbl.addWidget(self.canvas)
            self.setLayout(self.vbl)


  widget.canvas.figure.savefig('somefile')

should work

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] DateFormatter + Latex issue

2010-02-16 Thread Jae-Joon Lee
On Tue, Feb 16, 2010 at 5:25 PM, Filipe Pires Alvarenga Fernandes
ocef...@gmail.com wrote:
  I haven't notice the s before when using pts, but what is really
 strange is that pt does not work!


As I said, it is not supposed to work, because of some technical
reason. When there is a single line of text, it is hardly possible to
get to know the original baseline of the text.

By the way, the original problem that \n\n %b didn't work seems like
a actual bug (it is supposed to work without escaping '\n'). This
should now be fixed in the svn (r8135 in maint. branch and r8136 in
HEAD) . Still, it is recommended to adjust the pad of the ticklabels
instead of fiddling with newlines and etc.

Regards,

-JJ

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] half-filled markers, two-colors

2010-02-16 Thread John Hunter
On Mon, Feb 15, 2010 at 8:28 PM, T J tjhn...@gmail.com wrote:
 On Mon, Feb 15, 2010 at 5:22 PM, John Hunter jdh2...@gmail.com wrote:
 Very nice and thorough work.  I think this should be included, but
 I'll wait to hear from other developers before committing.  Could you
 confirm that the unit tests pass?

 import matplotlib
 matplotlib.test()


 Confirmed on rev 8133:

 Ran 124 tests in 341.585s

 FAILED (KNOWNFAIL=2, errors=2)
 and the errors were something to do with hexbin extents and the figimage 
 method.


Great -- I committed this patch in r8138


 I think the markerangle would also be a useful contribution, though it
 would render some of the markers redundant (eg triangle left, right,
 etc, would all just be triangles with different angles...)


 That was a concern I had as well, but I suppose  ^ v  (etc) could
 just be considered shortcuts to particular angles.  Presumably, we
 would not be removing them.  Correct?  Also, is the standard to have
 the angle specified in degrees?  So what is more useful:  markerangle
 or markerdeg?

We would definitely be leaving these as shortcuts and for backward
compatibility.  And yes the standard is to use degrees -- for
consistency with the text rotation property, we may want
markerrotation specified in degrees.


 The other difference is that when one specifies fillstyle='left', then
 it would only apply to the marker at 0 degrees.  Whereas, marker='v',
 fillstyle='left', markerangle=0  would correspond to marker='^',
 fillstyle='right', markerangle=180   (or something like that).

You can think about what the right way to do this is.  My first
inclination is that that left, right, etc, apply to the unrotated
marker, and then you apply the rotation.  So 'd' with markerrotation=0
and fillstyle='left' would be identical to 'd' with fillstyle='right'
and markerrotation=180.  But any convention you want to apply would
probably be fine as long as it is documented.  Note I am not sure this
is a terribly useful feature, but it might be marginally useful and it
seems like something that could be implemented unobtrusively.  So
don't kill yourself on it.

Thanks again for the nice work.

JDH

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] DateFormatter + Latex issue

2010-02-16 Thread John Hunter
On Tue, Feb 16, 2010 at 3:57 PM, Ernest Adrogué eadro...@gmx.net wrote:
 16/02/10 @ 16:20 (-0500), thus spake Filipe Pires Alvarenga Fernandes:
 \\  works for titles and label, but not for DateFormatter, but \vspace did
 the trick!

 Thanks again for the help.

 ps: I'm new to python, but maybe there is a way to mix Latex and unicode?

 Yes, the inputenc package from latex lets you use unicode.
 Try adding this to your script:
 plt.rc('text.latex', preamble='\usepackage[utf]{inputenc}')

 Note that this setting is not officially supported, whatever
 that means :)

I think it means that Darren, who did most of the heavy lifting for
these features, was getting tired of the endless line of additional
things TeX users wanted to do and the difficulties supporting these
across all platforms (eg MikTex on Windows) and drew a line in the
sand saying I'll add this stuff but if you report problems I may not
stay up all night trying to fix them.

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Color in table help please! I have already searched previous posts

2010-02-16 Thread Jae-Joon Lee
On Tue, Feb 16, 2010 at 2:15 PM, duckman tduck...@crowellsystems.com wrote:
 I am trying to make the table at the bottom and the lines the same color.  I
 took the code from one of the online examples and modified it to do most of
 what I want but cannot get the color in the table working properly! Can
 someone please help?  Thank you


Do you want the background of the row labels to match your line colors?
The answer seems to be so trivial and I'm not sure if this is what you want.

the_table = table(cellText=cellText,
 rowLabels=rowLabels, rowColours=linecolor,
 colLabels=colLabels,
 loc='bottom')

-JJ

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users