Re: [Matplotlib-users] specgram bug

2012-11-12 Thread G Jones
If you're using pyplot.specgram (i.e. "from pylab import *;
specgram(...)"), note that the plot is in dB, hence the negative
values.
I'm surprised this fact isn't mentioned in the documentation:
http://matplotlib.org/api/pyplot_api.html?highlight=specgram#matplotlib.pyplot.specgram

However, when in doubt, look at the code.

On Mon, Nov 12, 2012 at 12:28 PM, Paul Anton Letnes
 wrote:
> Heh,
>
> that's funny. Now then, why do my plots come out with negative values all 
> over the place? That's why I started digging around. After all, X * conj(X) 
> should be equal to the absolute square of X, right?
>
> Paul
>
>
> On 12. nov. 2012, at 21:00, G Jones wrote:
>
>> Hi,
>> If you trace back into the code further, you will see that the Pxx is
>> computed as X = fft(x), Pxx = X * conj(X) which is real, but the data
>> type will be complex with a ~0 imaginary part (up to floating point
>> precision). Thus the Pxx.real is just to ensure that the resulting
>> data type is real instead of complex to save memory.
>> Glenn
>>
>> On Mon, Nov 12, 2012 at 11:42 AM, Paul Anton Letnes
>>  wrote:
>>> Hi,
>>>
>>> not 100% sure this is a bug, but here goes:
>>>
>>> In file matplotlib/lib/matplotlib/mlab.py, the functions psd (power 
>>> spectral density) and specgram returns the real part of the fourier 
>>> transform.
>>> % grep -n Pxx.real mlab.py
>>> 390:return Pxx.real,freqs
>>> 470:Pxx = Pxx.real #Needed since helper implements generically
>>> (git version 4f902fac1c5bf267e3fdeb4c2045926d7498e85a, cloned from github 
>>> today)
>>>
>>> This all means that the specgram plot routine yields the real part of the 
>>> Fourier transform, rather than its absolute square (forgetting 
>>> normalization for simplicity of discussion). The definition of the PSD is 
>>> that it is the absolute square of the Fourier transform:
>>> https://en.wikipedia.org/wiki/Power_spectral_density#Energy_spectral_density
>>>
>>> Hence, I believe this is a bug which should be fixed.
>>>
>>> Cheers
>>> Paul
>>> --
>>> Monitor your physical, virtual and cloud infrastructure from a single
>>> web console. Get in-depth insight into apps, servers, databases, vmware,
>>> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
>>> Pricing starts from $795 for 25 servers or applications!
>>> http://p.sf.net/sfu/zoho_dev2dev_nov
>>> ___
>>> Matplotlib-users mailing list
>>> Matplotlib-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] specgram bug

2012-11-12 Thread G Jones
Hi,
If you trace back into the code further, you will see that the Pxx is
computed as X = fft(x), Pxx = X * conj(X) which is real, but the data
type will be complex with a ~0 imaginary part (up to floating point
precision). Thus the Pxx.real is just to ensure that the resulting
data type is real instead of complex to save memory.
Glenn

On Mon, Nov 12, 2012 at 11:42 AM, Paul Anton Letnes
 wrote:
> Hi,
>
> not 100% sure this is a bug, but here goes:
>
> In file matplotlib/lib/matplotlib/mlab.py, the functions psd (power spectral 
> density) and specgram returns the real part of the fourier transform.
> % grep -n Pxx.real mlab.py
> 390:return Pxx.real,freqs
> 470:Pxx = Pxx.real #Needed since helper implements generically
> (git version 4f902fac1c5bf267e3fdeb4c2045926d7498e85a, cloned from github 
> today)
>
> This all means that the specgram plot routine yields the real part of the 
> Fourier transform, rather than its absolute square (forgetting normalization 
> for simplicity of discussion). The definition of the PSD is that it is the 
> absolute square of the Fourier transform:
> https://en.wikipedia.org/wiki/Power_spectral_density#Energy_spectral_density
>
> Hence, I believe this is a bug which should be fixed.
>
> Cheers
> Paul
> --
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How Clear Points Without Wiping Everything?

2012-02-02 Thread G Jones
Note there is a typo. Ben assigned the output to "pts" but then referenced
"res".

On Thu, Feb 2, 2012 at 12:59 PM, Benjamin Root  wrote:

> On Thu, Feb 2, 2012 at 2:54 PM, Jim St.Cyr  wrote:
>
>>  On 2/2/2012 3:41 PM, Benjamin Root wrote:
>>
>> On Wed, Feb 1, 2012 at 4:07 PM, Jim St.Cyr  wrote:
>>
>>> Hello-
>>>
>>> Scenario:
>>>
>>> Basemap used to display the East Coast of the US and the Atlantic Ocean.
>>> Shapelib is used read a shapefile the contents of is pumped into a PyPlot
>>> subplot hosted Line Collection which overlays the ocean with a grid
>>> PyPlot text is used to label each grid with it's designator.
>>>
>>> What I want to do is plot a collection of points, save the result as a
>>> PNG,
>>> clear the first set of points, plot another collection of points, save
>>> the
>>> result, and so on.  The problem is the if I use the Pyplot clf function
>>> it wipes
>>> everything previously built.
>>>
>>> What do I need to do in order to clear just the points without clearing
>>> everything?
>>>
>>> Thank you.
>>>
>>> Jim
>>>
>>>
>> Jim,
>>
>> Sorry for the delay.  Most plotting functions in matplotlib returns a
>> Collection object.  These objects have a member function "remove()".
>>
>> >>> import matplotlib.pyplot as plt
>> >>> plt.ion()
>> >>> plt.plot([0, 1, 2, 3, 4], [4, 3, 2, 1, 0])
>> >>> pts = plt.scatter([1, 2, 3], [1, 2, 3])
>> >>> plt.show()# You see three points and a line
>> >>> res.remove()
>> >>> plt.show()   # Now you see only the line
>>
>>
>> I hope that helps!
>> Ben Root
>>
>>   Ben-
>>
>> Very helpful.  A question, how do you determine the object designator?
>> In your example above, res.remove(), where did the 'res' come from?
>>
>> Jim
>>
>
> It was assigned when I called scatter().  Just about any mpl plotting
> function (plot(), scatter(), hist(), etc.) returns an object.  Most of the
> time, users do not save the result into a variable, but if you want to do
> advanced tricks, you will need to save those returns.
>
> Ben Root
>
>
>
> --
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Horizontal bar chart with log x-axis, no filled boxes

2012-01-12 Thread G Jones
I think this is because the bar is going from zero to your value, so the
left edge of the rectangle becomes log(0). I see this when using the 'k'
and 'l' keys to interactively put a histogram on a log scale. Passing in
log=True for hist fixes this. I'm sure there's something similar that can
be done for bar/barh.
G

On Thu, Jan 12, 2012 at 7:03 AM, Christophe Pettus  wrote:

> I'm running into something odd in Matplotlib 1.1.  In drawing a horizontal
> bar chart (barh), if the x-axis scale is set to log, the rectangles are not
> drawn and filled; I just get small ticks at the right-hand position where
> the rectangle should end.  Interestingly, if I add a second, stacked barh
> to the same axes, that second set of rectangles draws fine, even though the
> first does not.
>
> If I simply comment out the call setting the x axis to log, it works
> properly.
>
> Any thoughts?
> --
> -- Christophe Pettus
>   x...@thebuild.com
>
>
>
> --
> RSA(R) Conference 2012
> Mar 27 - Feb 2
> Save $400 by Jan. 27
> Register now!
> http://p.sf.net/sfu/rsa-sfdev2dev2
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
--
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting points/locations from data file

2011-04-19 Thread G Jones
  xtxt=1.
> ytxt=0.
> parallels = arange(-90.,90.,30.)
> if startlon==-180:
> meridians = arange(-180.,180.,60.)
> else:
> meridians = arange(0.,360.,60.)
>
> if verbose>1: print m.__doc__
> xsize = rcParams['figure.figsize'][0]
> fig=figure(figsize=(xsize,m.aspect*xsize))
> #ax = fig.add_axes([0.08,0.1,0.7,0.7],axisbg='white')
> ax = fig.add_axes([0.06,0.00,0.8,1.0],axisbg='white')
> # make a pcolor plot.
> #x, y = m(lons, lats)
> #p = m.pcolor(x,y,maskdat,shading='flat',cmap=cmap)
> #clim(*colorbounds)
>
> # axes units units are left, bottom, width, height
> #cax = axes([0.85, 0.1, 0.05, 0.7])  #  colorbar axes for map w/ no
> graticule
> cax = axes([0.88, 0.1, 0.06, 0.81])  #  colorbar axes for map w/ graticule
>
> axes(ax)  # make the original axes current again
>
> #Plot symbol at station locations#
>
> #lines=open('file2.txt','r').readlines()
>
> #(lats,lons)=([],[])
> #for line in lines:
> #(lat,lon)=line.strip().split(',')
> #lats.append(float(lat))
> #lons.append(float(lon))
>
> #for i in range(len(lons)):
> #plt.plot(lats,lons,'*')
>
> #plt.plot(lons,lats,'*')
>
> #data = csv2rec('file2.txt',delimiter=',')
>
> #plot(data[:,0],data[:,1],'o')
>
> #data = csv2rec('file2.txt',delimiter=' ',names=['lat','lon'])
>
> #plot(data['lat'],data['lon'],'o')
>
> data = np.loadtxt('file2.txt')
>
> plot(data[:,0],data[:,1],'o')
>
> xpt,ypt = m(-75.0,43.0)
> text(xpt,ypt,'*')
>
>
> # draw coastlines and political boundaries.
> m.drawcoastlines()
> m.drawcountries()
> m.drawstates()
> # draw parallels and meridians.
> # label on left, right and bottom of map.
> m.drawparallels(parallels,labels=[1,0,0,0])
> m.drawmeridians(meridians,labels=[1,1,0,1])
>
> #if plotfile:
> #savefig(plotfile, dpi=72, facecolor='w', bbox_inches='tight',
> edgecolor='w', orientation='portrait')
> #else:
> #show()
>
> #plt.savefig('map.png')
> plt.savefig('map.eps')
> #  comment show to mass produce
>
>
>
>
> --- On *Tue, 4/19/11, G Jones * wrote:
>
>
> From: G Jones 
>
> Subject: Re: [Matplotlib-users] plotting points/locations from data file
> To: "Michael Rawlins" 
> Cc: "Ian Bell" , Matplotlib-users@lists.sourceforge.net
> Date: Tuesday, April 19, 2011, 8:12 PM
>
>
> No need for a header, but I guess my example was a little too simple. You
> could do:
> data = csv2rec(filename,delimiter=' ',names=['lat','lon'])
> plot(data['lat'],data['lon'],'o')
>
> or you could do
> data = np.loadtxt(filename)
> plot(data[:,0],data[:,1],'o')
>
> In general, I strongly recommend developing with ipython --pylab. That way
> all the documentation is at your fingertips using the ? and ?? notation.
>
>
--
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting points/locations from data file

2011-04-19 Thread G Jones
No need for a header, but I guess my example was a little too simple. You
could do:
data = csv2rec(filename,delimiter=' ',names=['lat','lon'])
plot(data['lat'],data['lon'],'o')

or you could do
data = np.loadtxt(filename)
plot(data[:,0],data[:,1],'o')

In general, I strongly recommend developing with ipython --pylab. That way
all the documentation is at your fingertips using the ? and ?? notation.


On Tue, Apr 19, 2011 at 5:03 PM, Michael Rawlins wrote:

>
> Do I need to add something to the header(?) at top of file to use csv2rec?
>
>
> import sys,getopt
>
> from mpl_toolkits.basemap import Basemap, shiftgrid, cm
> from mpl_toolkits.basemap import  NetCDFFile
> from pylab import *
>
>
>
>
> --- On *Tue, 4/19/11, Ian Bell * wrote:
>
>
> From: Ian Bell 
> Subject: Re: [Matplotlib-users] plotting points/locations from data file
> To: "G Jones" 
> Cc: "Michael Rawlins" ,
> Matplotlib-users@lists.sourceforge.net
> Date: Tuesday, April 19, 2011, 7:35 PM
>
>
> Have to say I whole-heartedly agree with Glenn.  One problem I have run
> into is a funky file headers where I want to skip lines 1,2,3, and 4, but
> line 3 is my real header line which doesn't work so well with either of the
> below solutions.  I had to write my own wrapper to deal with these weird
> types of files.
>
> Ian
>
> 
> Ian Bell
> Graduate Research Assistant
> Herrick Labs
> Purdue University
> email: ib...@purdue.edu <http://mc/compose?to=ib...@purdue.edu>
> cell: (607)227-7626
>
>
> On Tue, Apr 19, 2011 at 7:32 PM, G Jones 
> http://mc/compose?to=glenn.calt...@gmail.com>
> > wrote:
>
> You may find it easier to use mlab.csv2rec or numpy.loadtxt.
>
> e.g.
>
> data = csv2rec(filename,delimiter=' ')
> plot(data[:,0],data[:,1],'o')
>
>
>
> On Tue, Apr 19, 2011 at 4:26 PM, Michael Rawlins 
> http://mc/compose?to=rawlin...@yahoo.com>
> > wrote:
>
>
> Sorry I should have mentioned that longitudes are negative; there is a '-'
> before each longitude, like so:
>
> 39.4670  -76.1670
> 46.4000  -74.7670
> 45.3830  -75.7170
> 43.6170  -79.3830
> 45.5170  -73.4170
>
>
> Also the plt.text line you sent had lon[i] rather than lons[i].  I
> corrected that and changed my longitudes to not have the '-' sign and the
> code ran without error. Could the '-' be causing a problem?  I need to input
> the lat, lon as in the file as shown above.
>
> Mike
>
>
> --- On *Tue, 4/19/11, Ian Bell 
> http://mc/compose?to=ib...@purdue.edu>
> >* wrote:
>
>
> From: Ian Bell http://mc/compose?to=ib...@purdue.edu>>
> Subject: Re: [Matplotlib-users] plotting points/locations from data file
> To: "Michael Rawlins" 
> http://mc/compose?to=rawlin...@yahoo.com>
> >
> Cc: 
> Matplotlib-users@lists.sourceforge.net<http://mc/compose?to=Matplotlib-users@lists.sourceforge.net>
> Date: Tuesday, April 19, 2011, 7:22 PM
>
>
> If you want to plot a given marker at the point, for instance a circle,
> replace the last line of my code plt.text.. with
>
> plt.plot(lats,lons,'o')
>
> for a circle, or
>
> plt.plot(lats,lons,'s')
>
> for a square.  Refer to 
> Plot<http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.plot>for
>  more information on the markers you can use.  You are getting the error
> because you have a delimiter different than a single space, so it isn't
> splitting the line.  Replace ' '  in the split command with your whitespace
> delimiter.  Is it a tab? Then you want '\t' .
>
> Good luck,
> Ian
>
> 
> Ian Bell
> Graduate Research Assistant
> Herrick Labs
> Purdue University
> email: ib...@purdue.edu <http://mc/compose?to=ib...@purdue.edu>
> cell: (607)227-7626
>
>
> On Tue, Apr 19, 2011 at 7:14 PM, Michael Rawlins 
> http://mc/compose?to=rawlin...@yahoo.com>
> > wrote:
>
>
> Yes, there is whitespace between each lat and lon on each line.  But,
> actually, I'd simply like to plot a dot at each location.  The '1' was there
> in my example because I do not yet know how to plot a particular symbol.
> Here is what I got when I tried the code you just suggested.
>
> Traceback (most recent call last):
>   File "test.py", line 319, in 
>
> (lat,lon)=line.strip().split(' ')
> ValueError: too many values to unpack
>
>
> There are 203 records in the data file.  Line 319 of test.py is this:
>
>
> (lat,lon)=line.strip().split(' ')
>

Re: [Matplotlib-users] plotting points/locations from data file

2011-04-19 Thread G Jones
You may find it easier to use mlab.csv2rec or numpy.loadtxt.

e.g.

data = csv2rec(filename,delimiter=' ')
plot(data[:,0],data[:,1],'o')


On Tue, Apr 19, 2011 at 4:26 PM, Michael Rawlins wrote:

>
> Sorry I should have mentioned that longitudes are negative; there is a '-'
> before each longitude, like so:
>
> 39.4670  -76.1670
> 46.4000  -74.7670
> 45.3830  -75.7170
> 43.6170  -79.3830
> 45.5170  -73.4170
>
>
> Also the plt.text line you sent had lon[i] rather than lons[i].  I
> corrected that and changed my longitudes to not have the '-' sign and the
> code ran without error. Could the '-' be causing a problem?  I need to input
> the lat, lon as in the file as shown above.
>
> Mike
>
>
> --- On *Tue, 4/19/11, Ian Bell * wrote:
>
>
> From: Ian Bell 
> Subject: Re: [Matplotlib-users] plotting points/locations from data file
> To: "Michael Rawlins" 
> Cc: Matplotlib-users@lists.sourceforge.net
> Date: Tuesday, April 19, 2011, 7:22 PM
>
>
> If you want to plot a given marker at the point, for instance a circle,
> replace the last line of my code plt.text.. with
>
> plt.plot(lats,lons,'o')
>
> for a circle, or
>
> plt.plot(lats,lons,'s')
>
> for a square.  Refer to 
> Plotfor
>  more information on the markers you can use.  You are getting the error
> because you have a delimiter different than a single space, so it isn't
> splitting the line.  Replace ' '  in the split command with your whitespace
> delimiter.  Is it a tab? Then you want '\t' .
>
> Good luck,
> Ian
>
> 
> Ian Bell
> Graduate Research Assistant
> Herrick Labs
> Purdue University
> email: ib...@purdue.edu 
> cell: (607)227-7626
>
>
> On Tue, Apr 19, 2011 at 7:14 PM, Michael Rawlins 
> http://mc/compose?to=rawlin...@yahoo.com>
> > wrote:
>
>
> Yes, there is whitespace between each lat and lon on each line.  But,
> actually, I'd simply like to plot a dot at each location.  The '1' was there
> in my example because I do not yet know how to plot a particular symbol.
> Here is what I got when I tried the code you just suggested.
>
> Traceback (most recent call last):
>   File "test.py", line 319, in 
>
> (lat,lon)=line.strip().split(' ')
> ValueError: too many values to unpack
>
>
> There are 203 records in the data file.  Line 319 of test.py is this:
>
>
> (lat,lon)=line.strip().split(' ')
>
>
> --- On *Tue, 4/19/11, Ian Bell 
> http://mc/compose?to=ib...@purdue.edu>
> >* wrote:
>
>
> From: Ian Bell http://mc/compose?to=ib...@purdue.edu>>
> Subject: Re: [Matplotlib-users] plotting points/locations from data file
> To: "Michael Rawlins" 
> http://mc/compose?to=rawlin...@yahoo.com>
> >
> Cc: 
> Matplotlib-users@lists.sourceforge.net
> Date: Tuesday, April 19, 2011, 6:52 PM
>
>
> To clarify, you are trying to read in a set of (lat,lon) points in a file
> that is space delimited, store the data, and then put a text marker at each
> point, with each point numbered in order?  The critical part is that you
> want to use a list (or numpy array) instead of a dictionary.  Something like
> this ought to do (don't have MPL on this computer though - pretty sure this
> should work):
>
> lines=open('file.txt','r').readlines()
> (lats,lons)=([],[])
> for line in lines:
> (lat,lon)=line.strip().split(' ')
> lats.append(float(lat))
> lons.append(float(lon))
>
> for i in range(len(lons)):
> plt.text(lats[i],lon[i],str(i+1),ha='center',va='center',color='white')
>
> I'm sure there are a bunch of more compact ways to do this, but this should
> work.
>
> Ian
> 
> Ian Bell
> Graduate Research Assistant
> Herrick Labs
> Purdue University
> email: ib...@purdue.edu 
> cell: (607)227-7626
>
>
> On Tue, Apr 19, 2011 at 4:09 PM, Michael Rawlins 
> http://mc/compose?to=rawlin...@yahoo.com>
> > wrote:
>
>
> I'm trying to plot a series of points/locations on a map. I'm reading the
> latitudes and longitudes from a file, with each lat, lon pair on each record
> (line).  Here is the code:
>
> def make_float(line):
>lati, longi = line.split()
>return float(lati), float(longi)
>
> my_dict = {}
> with open("file.txt") as f:
>for item in f:
>lati,longi = make_float(item)
>my_dict[lati] = longi
>
> xpt,ypt = m(-76.1670,39.4670 )
> plt.text(xpt,ypt,'1',color='white')
>
> #print my_dict
>
> The matplotlib code which I've previously used to plot a single point on
> the map is below, with longitude and latitude in ( ):
>
> xpt,ypt = m(-70.758392,42.960445)
> plt.text(xpt,ypt,'1',color='white')
>
> When replacing (-70.758392,42.960445) with (longi,lati), the code plots
> only a single '1' at the location of just the last coordinate pair in the
> file. So now I only need to plot them all. Does the code I've implemented
> have an implicit loop to it?
>
> Mike
>
>
>
>
> ---

[Matplotlib-users] Updating legends in dynamic plot

2010-09-06 Thread G Jones
Hello,
I have a Qt4 application with dynamic embedded matplotlib plotting.
The application allows the user to add and remove lines from the plot.
This all works well, but I have found that updating the legend is
causing a memory leak. What is the proper way to update the legend in
an animated/dynamic context? The attached stand alone example
exemplifies the problem. On my system, with matplotlib.__version__
'1.0.0' compiled from SVN, the memory slowly increases as the script
runs. This does not happen if I remove the ax.legend() call. The del
ax.legend_ line seems to have no effect. I tried finding the artists
associated with the legend What's the appropriate way to update the
legend to avoid this behavior? I just found ax.legend_.remove() but it
raises NotImplementedError

Thanks,
Glenn
import matplotlib
matplotlib.use('Qt4Agg')
import matplotlib.pyplot as plt
import numpy as np

f = plt.figure()
ax = f.add_subplot(111)

l, = ax.plot(np.arange(100),np.random.randn(100),label='hi',animated=True)
ax.legend()
print "press enter to start"
raw_input()

for k in range(1):
l.set_ydata(np.random.randn(100))
del ax.legend_
ax.legend() #prop = matplotlib.font_manager.FontProperties(size='small'))
f.canvas.draw()--
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Bug with pcolorfast

2009-08-13 Thread G Jones
Hello,
Executing the following commands from ipython --pylab produces the error
below:

ax = subplot(111)
ax.pcolorfast(randn(100,100))
ax.set_xlim(2000,2001)
draw()

I ran into the error in a more complicated script, but this seems to be a
simple example to reproduce it.
I notice if I instead use:
ax.set_xlim(400,500)
draw()
I get the expected behavior, so it seems to be a combination of the width
being smaller than the extent, and the drawing area being off screen.

My matplot lib info is

In [19]: matplotlib.get_backend()
Out[19]: 'Qt4Agg'

In [20]: matplotlib.__version__
Out[20]: '1.0.svn'

This version was built from SVN just a couple of days ago.

Error traceback:


---
ZeroDivisionError Traceback (most recent call last)

/home/obs/workspace/backend/ in ()

/usr/local/lib/python2.6/dist-packages/matplotlib/pyplot.pyc in draw()
350 def draw():
351 'redraw the current figure'
--> 352 get_current_fig_manager().canvas.draw()
353
354 def savefig(*args, **kwargs):

/usr/local/lib/python2.6/dist-packages/matplotlib/backends/backend_qt4agg.pyc
in draw(self)
128 if DEBUG: print "FigureCanvasQtAgg.draw", self
129 self.replot = True
--> 130 FigureCanvasAgg.draw(self)
131 self.update()
132

/usr/local/lib/python2.6/dist-packages/matplotlib/backends/backend_agg.pyc
in draw(self)
313
314 self.renderer = self.get_renderer()
--> 315 self.figure.draw(self.renderer)
316
317 def get_renderer(self):

/usr/local/lib/python2.6/dist-packages/matplotlib/artist.pyc in
draw_wrapper(artist, renderer, *kl)
 44 def draw_wrapper(artist, renderer, *kl):
 45 before(artist, renderer)
---> 46 draw(artist, renderer, *kl)
 47 after(artist, renderer)
 48

/usr/local/lib/python2.6/dist-packages/matplotlib/figure.pyc in draw(self,
renderer)
773
774 # render the axes

--> 775 for a in self.axes: a.draw(renderer)
776
777 # render the figure text


/usr/local/lib/python2.6/dist-packages/matplotlib/artist.pyc in
draw_wrapper(artist, renderer, *kl)
 44 def draw_wrapper(artist, renderer, *kl):
 45 before(artist, renderer)
---> 46 draw(artist, renderer, *kl)
 47 after(artist, renderer)
 48

/usr/local/lib/python2.6/dist-packages/matplotlib/axes.pyc in draw(self,
renderer, inframe)
   1685 if len(self.images)<=1 or
renderer.option_image_nocomposite():
   1686 for im in self.images:
-> 1687 im.draw(renderer)
   1688 else:
   1689 # make a composite image blending alpha


/usr/local/lib/python2.6/dist-packages/matplotlib/artist.pyc in
draw_wrapper(artist, renderer, *kl)
 44 def draw_wrapper(artist, renderer, *kl):
 45 before(artist, renderer)
---> 46 draw(artist, renderer, *kl)
 47 after(artist, renderer)
 48

/usr/local/lib/python2.6/dist-packages/matplotlib/image.pyc in draw(self,
renderer, *args, **kwargs)
134 self.axes.get_yscale() != 'linear'):
135 warnings.warn("Images are not supported on non-linear
axes.")
--> 136 im = self.make_image(renderer.get_image_magnification())
137 im._url = self.get_url()
138 l, b, widthDisplay, heightDisplay = self.axes.bbox.bounds

/usr/local/lib/python2.6/dist-packages/matplotlib/image.pyc in
make_image(self, magnification)
424
425 # resize viewport to display

--> 426 rx = widthDisplay / numcols
427 ry = heightDisplay  / numrows
428 im.apply_scaling(rx*sx, ry*sy)

ZeroDivisionError: float division
--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Preferred Qt4 version with 0.98.3

2008-10-16 Thread G Jones
The problem seems to be fixed after updating SIP from 4.7 from the ubuntu
repositories to 4.7.7 from the source. I think it had to do with mixing
threading.Thread with a Qt application, but I'm not entirely sure.
Thanks for the info anyway,
Glenn

On Wed, Oct 15, 2008 at 6:00 AM, Michael Droettboom <[EMAIL PROTECTED]> wrote:

> I'm using Qt 4.3.0/PyQt 4.2, compiled from source on RHEL4 with no
> problems, so it's not necessarily that your version is too old.
>
> Once you have a script to reproduce and (ideally) a gdb backtrace, that
> should help us narrow down on the root cause.
>
> Mike
>
> G Jones wrote:
>
>> Hello,
>> I'm trying to track down a segfault when a canvas.draw() call is made in
>> my GUI program using the Qt4Agg backend. I am running matplotlib 0.98.3 and
>> Qt 4.3.2. <http://4.3.2.> I know the Qt version is a bit old, so I wanted
>> to check if I should be suspicious of version incompatibility. I am working
>> on a script to demonstrate the segfault.
>> Thanks,
>> Glenn
>> 
>>
>> -
>> 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=100&url=/
>> 
>>
>> ___
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>
> --
> Michael Droettboom
> Science Software Branch
> Operations and Engineering Division
> Space Telescope Science Institute
> Operated by AURA for NASA
>
>
-
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=100&url=/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Preferred Qt4 version with 0.98.3

2008-10-15 Thread G Jones
Hello,
I'm trying to track down a segfault when a canvas.draw() call is made in my
GUI program using the Qt4Agg backend. I am running matplotlib 0.98.3 and Qt
4.3.2. I know the Qt version is a bit old, so I wanted to check if I should
be suspicious of version incompatibility. I am working on a script to
demonstrate the segfault.
Thanks,
Glenn
-
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=100&url=/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Axes other than pixels with imshow

2008-09-21 Thread G Jones
Hello,
Is it possible to label the axes of an imshow plot with something other than
pixel number? I want to use imshow for speed, but also would like to be able
to put arbitrary X and Y axes vectors on, as in pcolor(x,y,z)
Thanks,
Glenn
-
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=100&url=/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Xlib: extension "XInputExtension" missing on display "ubuntu.local:1.0".

2008-06-19 Thread G Jones
Hello,
I am running matplotlib applications over VNC and during the
initialization segment, I always see the above error. It doesn't seem
to cause any problems, but I am curious what is causing it. Does
anyone have an idea? This happens using the Qt4Agg backend at least.
It seems to occur right when I first call ax.plot(...)
Thanks,
Glenn

-
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] Bug with blitting in Qt4Agg backend

2008-05-19 Thread G Jones
On 5/19/08, John Hunter <[EMAIL PROTECTED]> wrote:
> On Mon, May 19, 2008 at 2:36 AM, G Jones <[EMAIL PROTECTED]> wrote:
>  > Hello,
>  > I am experiencing a bug when trying to blit a canvas that contains two
>  > axes, one with a line plot and the other with an imshow plot. The
>  > attached example, QtBlitBugDemo.py demonstrates the problem. As is, on
>  > my machine, the
>  > imshow plot updates correctly, but the line plot acts like the
>  > background is not being restored correctly, the lines keep piling up
>  > on top of each other, even though I am explicitly restoring a clean
>  > background before drawing the artist. If I simply comment out the
>  > line:
>  >   self.specPlotB.draw_artist(self.specArtistB)
>  > which draws the imshow artist, the line plot behaves correctly.
>  > I haven't been able to figure out what is causing this behavior.
>  > I am using r5186 from the SVN. The output from running with debug mode
>  > on is below.
>
>
> I don't have qt installed so I can't test this here, but poking
>  through the code one thing looks badly wrong (though it may be
>  unrelated to your problem)
>
> if self.autoSpec:
> self.specPlotT.relim()
> self.specPlotT.autoscale_view(scalex = False, scaley = True)
>
>  you cannot change the viewlim when updating your animated artists (nor
>  should you change the grid).  The idea is
>
>
>
>   - draw (everything but animated by default)
>
>
>   --  copy the background
>
>   start animation loop:
>
>   * restore background
>
>   * update *only* your animated artists and change nothing else
>  about the figure (viewlim, grid, labels, etc)
>
>   * draw your animated artists
>
>   * blit
>
>  If you need to change anything else, you need to invoke a draw, then a
>  copy a new background, and then proceed through the animation loop.
>  Also, be aware that zorder is not respected for animated artists, so I
>  think you will want to update and draw your image before the lines.
>
>  JDH
>

Thank you for the notes. I found that if I draw the image before the
line, it works as expected. Even though you say I shouldn't try to
change the viewlim when blitting, this does seem to work, the plot
stays within bounds. The axes do not display the correct values until
I resize the window (which forces a full redraw), but I can live with
that.
However, I am curious how one should achieve dynamic autoscaling while
doing an animated plot. Doing a full draw each iteration is too slow.
Is there any other way?

Thanks again,
Glenn

-
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


[Matplotlib-users] Bug with blitting in Qt4Agg backend

2008-05-19 Thread G Jones
Hello,
I am experiencing a bug when trying to blit a canvas that contains two
axes, one with a line plot and the other with an imshow plot. The
attached example, QtBlitBugDemo.py demonstrates the problem. As is, on
my machine, the
imshow plot updates correctly, but the line plot acts like the
background is not being restored correctly, the lines keep piling up
on top of each other, even though I am explicitly restoring a clean
background before drawing the artist. If I simply comment out the
line:
   self.specPlotB.draw_artist(self.specArtistB)
which draws the imshow artist, the line plot behaves correctly.
I haven't been able to figure out what is causing this behavior.
I am using r5186 from the SVN. The output from running with debug mode
on is below.

Thanks for any help on this.
Glenn

matplotlib data path /usr/lib/python2.5/site-packages/matplotlib/mpl-data
loaded rc file /home/glenn/.matplotlib/matplotlibrc
matplotlib version 0.98pre
verbose.level debug
interactive is False
units is True
platform is linux2
loaded modules: ['numpy.lib.pkgutil', 'numpy.lib.tempfile',
'numpy.ma.types', 'xml.sax.urlparse', 'distutils', 'matplotlib.errno',
'matplotlib.matplotlib', '_bisect', 'numpy.core.defchararray',
'pprint', 'numpy.lib.bz2', 'matplotlib.tempfile',
'distutils.sysconfig', 'ctypes._endian', 'encodings.encodings',
'matplotlib.colors', 'numpy.core.numerictypes', 'numpy.testing.sys',
'numpy.core.info', 'xml', 'numpy.fft.types', 'numpy.ma.operator',
'numpy.ma.cPickle', 'struct', 'numpy.random.info', 'tempfile', 'mmap',
'xml.sax.urllib', 'numpy.linalg', 'numpy.testing.operator', 'imp',
'compiler.sys', 'collections', 'compiler.pyassem', 'numpy.core.umath',
'_struct', 'unittest', 'compiler.new', 'numpy.lib.numpy',
'numpy.testing.types', 'compiler.ast', 'numpy.ma.sys', 'zipimport',
'string', 'numpy.testing.os', 'matplotlib.locale',
'numpy.lib.arraysetops', 'numpy.testing.unittest',
'numpy.lib.inspect', 'encodings.utf_8', 'matplotlib.__future__',
'numpy.linalg.numpy', 'pytz.tzinfo', 'numpy.ctypeslib',
'numpy.testing.re', 'itertools', 'numpy.version', 'numpy.lib.re',
'distutils.re', 'ctypes.os', 'compiler.token', 'numpy.core.os',
'compiler', 'numpy.lib.type_check', 'httplib', 'bisect', 'signal',
'compiler.consts', 'numpy.lib._datasource', 'random',
'numpy.ma.extras', 'token', 'numpy.fft.fftpack_lite', 'shlex',
'ctypes.ctypes', 'xml.sax.xmlreader', 'matplotlib.pytz',
'numpy.__builtin__', 'numpy.testing.shlex', 'dis', 'pytz.tzfile',
'cStringIO', 'zlib', 'numpy.numpy', 'matplotlib.StringIO', 'locale',
'numpy.add_newdocs', 'numpy.lib.getlimits', 'PyQt4',
'compiler.transformer', 'xml.sax.saxutils', 'compiler.struct',
'pkgutil', 'compiler.parser', 'numpy.lib.sys', 'encodings',
'compiler.symbol', 'numpy.lib.io', 'numpy.ma.itertools', 'StringIO',
'dateutil', 'pydoc', 'pytz.cStringIO', 'numpy.imp', 'numpy.ctypes',
'matplotlib.warnings', 'rfc822', 'matplotlib.string', 'pytz.pytz',
'urllib', 'matplotlib.sys', 're', 'numpy.lib._compiled_base',
'numpy.core.mmap', 'new', 'numpy.lib.struct', 'symbol', 'math',
'numpy.fft.helper', 'fcntl', 'numpy.ma.warnings', 'compiler.imp',
'UserDict', 'inspect', 'distutils.os', 'matplotlib', 'urllib2',
'pytz.os', 'fnmatch', 'numpy.lib.info', 'numpy.testing',
'numpy.testing.glob', 'numpy.lib.warnings', 'ctypes.struct', 'codecs',
'numpy.core._sort', 'PyQt4.QtGui', 'compiler.visitor', 'md5',
'_locale', 'matplotlib.sre_constants', 'matplotlib.os', 'thread',
'numpy.lib.ufunclike', 'numpy.core.memmap', 'traceback',
'numpy.core._dotblas', 'numpy.testing.warnings', 'weakref',
'numpy.core._internal', 'numpy.fft.fftpack', 'opcode',
'numpy.core.scalarmath', 'numpy.linalg.lapack_lite', 'ctypes',
'distutils.sys', 'os', 'marshal', 'numpy.lib.shutil', '__future__',
'numpy.core.string', 'matplotlib.copy', 'xml.sax.types',
'numpy.random.numpy', '_sre', 'numpy.lib.gzip', 'numpy.core.sys',
'numpy.random', 'numpy.testing.utils', '__builtin__',
'numpy.lib.twodim_base', 'numpy.ma.core', 'matplotlib.re',
'numpy.core.cPickle', 'base64', 'compiler.dis', 'operator',
'numpy.testing.parametric', 'numpy.core.arrayprint',
'distutils.string', 'ctypes._ctypes', '_heapq', 'ctypes.sys', 'heapq',
'numpy.os', 'posixpath', 'numpy.lib.financial',
'numpy.core.multiarray', 'errno', 'numpy.testing.numpy', '_socket',
'binascii', 'numpy.lib.compiler', 'sre_constants',
'compiler.cStringIO', 'datetime', 'compiler.os', 'matplotlib.md5',
'types', 'pytz.sys', 'tokenize', 'FigureWindow', 'xml.sax.handler',
'numpy.core.numpy', 'numpy', 'numpy.lib.urlparse',
'matplotlib.dateutil', 'numpy.core.defmatrix', 'xml.sax.os',
'cPickle', 'matplotlib.xml', '_codecs', 'numpy.testing.difflib',
'matplotlib.traceback', 'numpy.__config__', 'numpy.fft.info',
'numpy.lib.types', 'pytz', 'matplotlib.pyparsing',
'compiler.copy_reg', 'numpy.ma.numpy', 'copy', 'numpy.core.re',
'socket', '_types', 'numpy.core.fromnumeric', 'hashlib',
'compiler.future', 'matplotlib.cbook', 'numpy.core.copy_reg',
'numpy.lib.scimath', 'numpy.fft', 'numpy.lib', '_ctypes',
'apport_pyth

[Matplotlib-users] hist is broken in SVN when using numpy 1.1.0.dev5077

2008-05-19 Thread G Jones
Hello,
I am using r5186 from the SVN with numpy 1.1.0.dev5077. When I try
hist(rand(512),arange(-128,127))
I get:
---
 Traceback (most recent call last)

/home/gej/casper_work/backend/qtSpec/src/ in ()

/usr/lib/python2.5/site-packages/matplotlib/pyplot.py in hist(*args, **kwargs)
   1688 hold(h)
   1689 try:
-> 1690 ret =  gca().hist(*args, **kwargs)
   1691 draw_if_interactive()
   1692 except:

/usr/lib/python2.5/site-packages/matplotlib/axes.py in hist(self, x,
bins, normed, cumulative, bottom, histtype, align, orientation, width,
log, **kwargs)
   5472 if not self._hold: self.cla()
   5473 n, bins = np.histogram(x, bins, range=None,
-> 5474 normed=bool(normed), new=True)
   5475
   5476 if cumulative:

: histogram() got an unexpected keyword
argument 'new'

I guess the new keyword argument has been deprecated?

-
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


[Matplotlib-users] bug in qtagg backend when blitting

2008-05-05 Thread G Jones
Hello,
Attached is a script that when run from ipython --pylab with your
backend setup for 'QtAgg' reproduces a bug I am seeing. If you run the
plot, you'll see a line plotted in blue as expected. Then when the
same figure is updated by blitting, the line turns red. I tried this
with green and it stayed green, but yellow went to cyan. It seems that
the byteswapping that is necessary for displaying colors correctly in
Qt is happening during a normal plot, but not when blitting. I tried
going through the code to determine the problem, I can only guess that
it lies somewhere in the FigureCanvasQTAgg.paintEvent, since that's
where I see to_ARGB etc.
Sorry I couldn't locate the bug precisely, I find it very difficult to
thread my way through all the backend classes.
Glenn
import matplotlib
matplotlib.use('QtAgg')
import pylab
import time

pylab.ion()

f = pylab.figure()
ax = f.add_subplot(111)
line, = ax.plot([1,2,3])
pylab.show()
time.sleep(1)
bbox = f.bbox
bg = f.canvas.copy_from_bbox(bbox)
time.sleep(1)
f.canvas.restore_region(bg)
time.sleep(1)
line.set_ydata([3,2,1])
ax.draw_artist(line)
f.canvas.blit(bbox)
time.sleep(1)-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] possible bug in FigureManagerQT: notify_axes_change never used

2008-05-05 Thread G Jones
Hello,
I don't know if this is a bug or not, but I notice that
notify_axes_change is defined in each FigureManager* __init__
function, and usually it is then passed to
self.canvas.figure.add_axobserver(notify_axes_change), but this is not
the case in FigureManagerQt, it is defined but never used in both
backend_qt and backend_qt4.
Glenn

-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Using the pylab figure system programmatically

2008-05-04 Thread G Jones
Hello,
I did some quick tests of using pylab.figure() to create a figure
window, and then accessing the canvas to do blitted animation, which
is working well. I also reimplemented the resizeEvent handler to
update the region to be blitted. However, I have one major problem,
that when I click the X on the figure window, the window closes and
then my application wittingly tries to blit it and gives the error:
self.SpecCanvas.blit(self.total_bbox)
  File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_qt4agg.py",
line 144, in blit
self.update(l, self.renderer.height-t, w, h)
RuntimeError: underlying C/C++ object has been deleted

I tried reimplementing the closeEvent handler, but my new handler
never seems to be executed. I am setting the close event handler like
this:
self.SpecCanvas.closeEvent = closePyl

def closePyl(self,event):
print "hi"
event.ignore()
self.parent().SpecCanvas = None

Any ideas about how to keep the window from being destroyed before I
have a chance to know about it?

Also, should I be using ion() or ioff() for this type of application?
It seems that either works fine, and I can zoom/pan even while
blitting.

Thanks,
Glenn

-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] when to call copy_from_bbox

2008-05-04 Thread G Jones
Hello,
I am again working on an application with animated plots using the
blitting method. I am using the Qt4 backend, but I had similar trouble
with the wx backend. The trouble is when I first get the bbox of the
plot to copy the background region, the bbox is incorrect, so the
wrong region is used for updating. I have added a resize event handler
(below) that works well. As soon as I resize the application the
graphs look fine. I have tried calling all of the following before
accessing the bbox to try and force the application to get to an
appropriate layout:
self.update()
self.repaint()
self.layout()
QApplication.processEvents()
QApplication.processEvents()
QApplication.flush()
I also plot a set of data that has the same x and y range as the
animated data, so I know the axis limits are not changing. When I
print the initial bbox, I get 30,15,270,285 and when I print it after
resizing, I get 30.8, 22, 277,417 which makes much more sense.
Here is the resize event handler:
self.update()
self.total_bbox = self.SpecPlotA
print self.total_bbox
self.bkg = self.SpecCanvas.copy_from_bbox(self.total_bbox)
Any ideas of how to get the initial plot to work?
Thanks
Glenn

-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Embedding matplotlib in Qt using Designer

2008-04-30 Thread G Jones
Hello,
I have decided to switch to the QtAgg backend because the Designer
software is very appealing. I succeeded in adding a custom widget
representing the FigureCanvasQTAgg, but when I compile the ui file, I
see that it tries to instantiate it as FigureCanvasQTAgg(Parent) where
Parent is the parent widget, which seems to be the standard format for
instantiating widgets. However, FigureCanvasQTAgg expects a figure as
an argument.
I have seen this tutorial:
http://www.scipy.org/Cookbook/Matplotlib/Qt_with_IPython_and_Designer
which suggests making a MatplotlibWidget to wrap the Canvas and set
everything up including the parent. I have written a version of this
for Qt4, but this seems like something that should be included in the
Qt4 backends. Any plans on adding this? I'd be happy to contribute.
Attached is my initial version.
Glenn
from PyQt4 import QtGui, QtCore
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg
from matplotlib.figure import Figure

class FigureCanvasQTAggWidget(FigureCanvasQTAgg):
def __init__(self, parent = None, width=3, height =3, dpi = 100):
self.fig = Figure(figsize=(width,height), dpi=dpi)
FigureCanvasQTAgg.__init__(self, self.fig)
self.setParent(parent)
self.setSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
self.updateGeometry()
from PyQt4 import QtGui, QtDesigner
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg
from matplotlib.figure import Figure
from FigureCanvasQTAggWidget import FigureCanvasQTAggWidget

class FigureCanvasQTAggWidgetPlugin(QtDesigner.QPyDesignerCustomWidgetPlugin):
def __init__(self, parent = None):
QtDesigner.QPyDesignerCustomWidgetPlugin.__init__(self)
self.initialized = False
def initialize(self,core):
if self.initialized:
return
self.initialized = True
def isInitialized(self):
return self.initialized
def createWidget(self, parent):
fc = FigureCanvasQTAggWidget(parent,width=2, height=2)
fc.figure.add_subplot(111)  #Show something other than a grey canvas
return fc
def name(self):
return "FigureCanvasQTAggWidget"
def group(self):
return "Display Widgets"
def icon(self):
return QtGui.QIcon(_logo_pixmap)
def toolTip(self):
return "Matplotlib Canvas"
def whatsThis(self):
return ""
def isContainer(self):
return False
def domXml(self):
return '\n'
def includeFile(self):
return "FigureCanvasQTAggWidget"  #Eventually part of matplotlib.backends.backend_qt4agg hopefully


_logo_16x16_xpm = [
"16 16 5 1",
"B c #00",
"r c #ff",
"g c #00ff00",
"b c #ff",
". c #ff",
"",
"....",
"..B.bB..",
"..Bb.B..",
"..B...b..B..",
"..B...b..B..",
"..B...b..B..",
"..B..b...B..",
"..B...b.bB..",
"..B..b.b.B..",
"..B..b...B..",
"..B..b...B..",
"..B.bB..",
"..Bb.B..",
"....",
""]

_logo_pixmap = QtGui.QPixmap(_logo_16x16_xpm)-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Developing with IPython

2008-04-28 Thread G Jones
Hello,
I appologize for a slightly off topic post, but I'm sure someone here
knows the answer. I like the idea of developing code interactively
with IPython, but I cannot get past one hurdle. I would like to write
my code in a module that I then import and instantiate classes or call
functions from interactively. However, when I try to do this in
IPython I find that after I import my code, it is cached and even
after restarting and reimporting, the changes are not recognized. What
is the paradigm people use to get around this, or what is the
preferred paradigm for interactive development using IPython.
Thanks,
Glenn

-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] animated plot with autoscaling

2008-04-26 Thread G Jones
Hi,
Thank you for pointing that out, that does indeed do what I want
mostly. However, while the data is autoscaled to the plot, the values
on the y axis are not updated and they remain at their original
values. I suspect this is because I am not giving a command to redraw
the axes. How would I go about doing that? I think I need to blit a
larger bbox that encompasses the axes as well, but I'm not sure how to
get that.
By the way, I found that self.ax1.autoscale_view(scalex=False, scaley
= True) seems to autoscale just the y axis and seems clearer than the
set_ylim code suggested below.
Thanks again,
Glenn

On 4/26/08, John Hunter <[EMAIL PROTECTED]> wrote:
> On Fri, Apr 25, 2008 at 1:19 AM, G Jones <[EMAIL PROTECTED]> wrote:
>  > Hello,
>  >  Thank you for the suggestion. However, I am refering to the
>  >  canvas.restore_region, draw_artist, blit, gui_repaint sort of
>  >  animation.
>  >  Glenn
>
>
> His suggestion is still correct -- after you update the line data and
>  before you call draw_artist, you can acll relim and autoscale_view as
>  Mattias suggested.  However, this will not always do what you want,
>  because it will autoscale both the x and the y.  In animated plots,
>  often you are just updating the ydata an want to manually control the
>  xlim and autoscale the ylim (eg strip charting).  In that case, I
>  would do :
>
> self.ax1.relim()
> self.ax1.set_ylim(*self.ax1.yaxis.major.locator.autoscale())
>
>   JDH
>

-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] animated plot with autoscaling

2008-04-24 Thread G Jones
Hello,
Thank you for the suggestion. However, I am refering to the
canvas.restore_region, draw_artist, blit, gui_repaint sort of
animation.
Glenn

On Thu, Apr 24, 2008 at 11:13 PM, Matthias Michler
<[EMAIL PROTECTED]> wrote:
> Hello Glenn
>
>  Do you refer to a special example?
>  Maybe the following helps you.
>  
> --
>  from pylab import *
>
>  ion()
>  ax = subplot(111)
>  # ... some plotting
>  ax.relim()  # reset intern limits of the current axes
>  ax.autoscale_view()   # reset axes limits
>
>  ioff()
>  show()
>  
> --
>
>  Good luck,
>  Matthias
>
>
>
>  On Friday 25 April 2008 08:01:24 G Jones wrote:
>  > I would like to extend the animated plot paradigm to an application
>  > where I need to autoscale the vertical axis each time the plot is
>  > updated. Any suggestions as to how to do so? I assume I need to tell
>  > the axis to autoscale, then draw the axis' artist. However, I am not
>  > sure how to do these things, I'm having trouble finding the
>  > appropriate methods in the matplotlib class documentation.
>  > Thanks,
>  > Glenn
>  >
>  > -
>  > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
>  > Don't miss this year's exciting event. There's still time to save $100.
>  > Use priority code J8TL2D2.
>  > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/java
>  >one ___
>  > 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 2008 JavaOne(SM) Conference
>  Don't miss this year's exciting event. There's still time to save $100.
>  Use priority code J8TL2D2.
>  
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
>  ___
>  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 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] animated plot with autoscaling

2008-04-24 Thread G Jones
I would like to extend the animated plot paradigm to an application
where I need to autoscale the vertical axis each time the plot is
updated. Any suggestions as to how to do so? I assume I need to tell
the axis to autoscale, then draw the axis' artist. However, I am not
sure how to do these things, I'm having trouble finding the
appropriate methods in the matplotlib class documentation.
Thanks,
Glenn

-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Different between canvas.draw() and canvas.restore_region()??

2008-04-24 Thread G Jones
I'm confused, because I don't see any place where self.canvas.draw is
called in the code1 version. Also, when I resize the figure, the
background region changes, so the plot gets messed up as I have
noticed before with this method. Does anyone know a good way to
recapture a clean background, in particular when the image is resized?
Thanks,
Glenn

On Mon, Apr 21, 2008 at 6:21 AM, John Hunter <[EMAIL PROTECTED]> wrote:
> On Sun, Apr 20, 2008 at 9:13 PM, hjc520070 <[EMAIL PROTECTED]> wrote:
>  >
>  >  Thanks for your help. I get it work. However, an interesting thing 
> appears.
>  >  The following two codes(code 1 and code 2) makes different result??? Only
>  >  set background in different place. Anyone can tell me why? I am eager to
>  >  know it.
>
>
>  In code2, you copy the background before the canvas is drawn, which is
>  wrong.  code 1 is the correct approach.  Calling ax.plot is not enough
>  to cause the background to be drawn.  You must call fig.canvas.draw
>  first.
>
>  JDH
>
>
>
>  -
>  This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
>  Don't miss this year's exciting event. There's still time to save $100.
>  Use priority code J8TL2D2.
>  
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
>  ___
>  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 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] speeding up imshow

2008-04-15 Thread G Jones
Numpy 1.0.3 and MPL 0.91.2. The image array is 256 x 1024. I found I
could speed things up a lot (~15ms update time) by setting my data to
be a 256 x 1024 x 4 array of uint8, so I guess the solution is to
handle color mapping myself. I appreciate any other suggestions.
Glenn

On 4/15/08, Eric Firing <[EMAIL PROTECTED]> wrote:
> Glenn,
>
>  What version of numpy are you using?  What version of matplotlib? And what
> are the dimensions of your image array?
>
>  Eric
>
>
>  G Jones wrote:
>
> > Thank you for the suggestion.
> > I now have the update time down to about 70 ms.
> > When I run the code through the profiler, I see that each plot update
> > requires a call to matplotlib.colors.Colormap.__call__,
> and each of
> > these calls takes 52 ms, 48 ms of which is spent inside the function
> > itself. This looks like it is the bulk of the delay, so if I can
> > optimize the Colormap.__call__ function, the performance should be
> > much improved. Unfortunately I cannot seem to get finer grained
> > information about what exactly is taking so long inside this function.
> > Can anyone provide any hints?
> > Thanks,
> > Glenn
> >
> > On Sat, Apr 12, 2008 at 7:02 PM, hjc520070 <[EMAIL PROTECTED]> wrote:
> >
> > >  I just use blit on imshow map, and work properly. Maybe the following
> code
> > >  will help you.
> > >
> > >  def ontimer()
> > >   canvas.restore_region(background)
> > >   im.set_array(Z)
> > >   ax.draw_artist(self.imList[i])
> > >   canvas.blit(ax.bbox)
> > >   canvas.gui_repaint()
> > >  --
> > >  View this message in context:
> http://www.nabble.com/speeding-up-imshow-tp16623430p16656693.html
> > >  Sent from the matplotlib - users mailing list archive at Nabble.com.
> > >
> >
>

-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] speeding up imshow

2008-04-14 Thread G Jones
Thank you for the suggestion.
I now have the update time down to about 70 ms.
When I run the code through the profiler, I see that each plot update
requires a call to matplotlib.colors.Colormap.__call__, and each of
these calls takes 52 ms, 48 ms of which is spent inside the function
itself. This looks like it is the bulk of the delay, so if I can
optimize the Colormap.__call__ function, the performance should be
much improved. Unfortunately I cannot seem to get finer grained
information about what exactly is taking so long inside this function.
Can anyone provide any hints?
Thanks,
Glenn

On Sat, Apr 12, 2008 at 7:02 PM, hjc520070 <[EMAIL PROTECTED]> wrote:
>
>  I just use blit on imshow map, and work properly. Maybe the following code
>  will help you.
>
>  def ontimer()
>canvas.restore_region(background)
>im.set_array(Z)
>ax.draw_artist(self.imList[i])
>canvas.blit(ax.bbox)
>canvas.gui_repaint()
>  --
>  View this message in context: 
> http://www.nabble.com/speeding-up-imshow-tp16623430p16656693.html
>  Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
>  -
>  This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
>  Don't miss this year's exciting event. There's still time to save $100.
>  Use priority code J8TL2D2.
>  
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
>  ___
>  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 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] speeding up imshow

2008-04-10 Thread G Jones
Hello,
I want to use imshow to make a real time waterfall plot. The attached
code is the core of my application, and it works, but it is quite
slow, around 200ms to update the plot. Is there a way to accelerate
this? I have seen the blitting demos, and they work well for the line
plots, but I could not figure out how to extend this functionality to
imshow plots. In theory I could throw all of my data into a bitmap
(since I don't really need the antialiasing etc provided by AGG) and
display that directly in WX, but the trouble with that is I want to
display the spectra at a given time and the waterfall plot with the
same X axis, thus computing the area to display the bitmap seems
tricky. Is there any built in MPL functionality for doing that?
One question about the blitting demos: they do not seem to work well
with resizing the window (which make sense because the blit buffer
never gets informed of the window size change). Has anyone modified
this code to allow it to work with resizing? I tried to connect to the
RESIZE event and recapture the base canvas, but did not have any luck.
Thanks,
Glenn
import  wx
import  wx.lib.newevent

import matplotlib
matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import Toolbar, FigureCanvasWxAgg
from matplotlib.figure import Figure

import pylab as p
import numpy
import os
import gc

import socket, time, string

if os.name == 'posix':
_time = time.time
else:
time = time.clock
import gui

class SpecFrame(gui.MainFrame):
def __init__(self, *args, **kwds):
gui.MainFrame.__init__(self, *args, **kwds)
self.PlotInit()
self.UpdateInterval = 0.5
self.spec_canvas.SetMinSize((50,50))
self.time_canvas.SetMinSize((50,50))
self.var_canvas.SetMinSize((50,50))
self.Bind(wx.EVT_TIMER, self.NewSpec)
self.t1 = None


def OnStart(self,event):
self.avg_count = 0
self.avg = numpy.zeros(1024)
self.wfall = numpy.zeros((256,1024))
self.ch = 100
self.timeseries = numpy.zeros(256)
self.start_time = _time()
self.LastUpdateTime = _time()
self.t1 = wx.Timer(self)
self.t1.Start(self.UpdateInterval*100)
def OnStop(self, event):
if self.t1:
self.t1.Stop()

 
def NewSpec(self,event):
spp = _time()
self.Status.SetStatusText("%.3f  %d %d" % ((spp-self.start_time)*1000, self.avg_count, len(gc.get_objects())),1)
self.start_time = spp
s = numpy.random.random((1024, ))
self.wfall[1:,:] = self.wfall[:-1,:]
self.wfall[0,:] = self.avg
self.timeseries[1:] = self.timeseries[:-1]
self.timeseries[0] = s[self.ch]
if self.avg_count == 1:
if spp - self.LastUpdateTime > self.UpdateInterval:
#self.plots[2].clear()
a = _time()
self.water_plot.imshow(numpy.log10(self.wfall+1).clip(0,5),aspect = 'auto')
#self.time_plot.plot(self.timeseries)
##self.timeplot.set_ydata(self.timeseries)
##self.plots[1].axes.set_ylim(self.timeseries.min(),self.timeseries.max())
#self.spec_plot.clear()
#self.spec_plot.plot(numpy.log10(self.avg+1))
#self.spec_plot.plot([self.ch],[numpy.log10(self.avg[self.ch]+1)],'ro')
##self.canvas.restore_region(self.bkg)
##self.specplot.set_ydata(numpy.log10(self.avg+1))
#self.spec_plot.axes.set_xlim(0,1023)
##self.plots[0].draw_artist(self.line)
#a = _time()
self.spec_canvas.draw()
#self.time_canvas.draw()
#try:
#self.queue.put(self.default_task,False)
#except:
#self.queue.get(False)
#print "Plot Dropped"
print "%f %f" % (_time() - a, _time())
#self.canvas.blit(self.plots[0].bbox)
self.LastUpdateTime = _time()
self.avg_count = 0
self.avg = s
else:
self.avg += s
self.avg_count += 1

def PlotInit(self):
self.spec_plot = self.spec_fig.add_axes([.1,.55,.8,.4])
self.spec_plot.grid(True)
#self.spec_plot.hold(False)
self.water_plot = self.spec_fig.add_axes([.1,.05,.8,.5],sharex = self.spec_plot)
self.water_plot.grid(True)
self.water_plot.hold(False)
self.time_plot = self.time_fig.add_subplot(1,1,1)
self.time_plot.grid(True)
self.time_plot.hold(False)
self.var_plot = self.var_fig.add_subplot(1,1,1)
self.var_plot.grid(True)
self.var_plot.hold(False)
self.spec_canvas.draw()
def Plot(self, n, *args, **kwds):
#self.plots[n].clear()
self.plots[n].plot(*args, **kwds)
self.plots[n].grid(True)
#self.canvas.draw()


if __nam