[Matplotlib-users] updating an image plot
Hi, I am trying to update the image plotted in a figure. From what I understood, this code should do the job: import pylab as p image=p.zeros((20,20)) p.ion() ax=p.imshow(image) p.draw() for i in range(10): print i p.ion() image[i,:]=i ax.set_array(image) p.draw() But the image is not updated at all what am I doing wrong? I have the 0.99.1.1 version of matplotlib. Cheers, Chiara _ Hotmail: Powerful Free email with security by Microsoft. https://signup.live.com/signup.aspx?id=60969-- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] realtime plotting was working with matplotlib 0.99.1.1 and it doesn't with matplotlib 1.0.0
Hi all, I have a script to update a plot in real time. It was working fine with matplotlib 0.99.1.1 but it doesn't work anymore with the new version. Here is the script: import numpy as n import pylab as p x=n.arange(10) y=n.random.randn(10) p.ion() fig=p.figure(1) ax=fig.add_subplot(111) line,=ax.plot(x,y,'ko-') for i in range(10): y=n.random.randn(10) line.set_data(x,y) p.draw() it is updating the plot correctly with matplotlib 0.99.1.1 when I run it with matplotlib 1.0.0 it doesn't show any picture at all Interestingly, if I add a line raw_input('ok') then it shows the plot and it updates it inside the loop x=n.arange(10) y=n.random.randn(10) p.ion() fig=p.figure(1) ax=fig.add_subplot(111) line,=ax.plot(x,y,'ko-') raw_input('ok?') for i in range(10): y=n.random.randn(10) line.set_data(x,y) p.draw() raw_input('ok?') Any idea why it is doing this? Is it a bug or am I missing something? Thanks for your help, Chiara -- Sell apps to millions through the Intel(R) Atom(Tm) Developer Program Be part of this innovative community and reach millions of netbook users worldwide. Take advantage of special opportunities to increase revenue and speed time-to-market. Join now, and jumpstart your future. http://p.sf.net/sfu/intel-atom-d2d___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] realtime plotting was working with matplotlib 0.99.1.1 and it doesn't with matplotlib 1.0.0
I think I am using TkAgg but I am not sure, how can I check it? From: ben.r...@ou.edu Date: Fri, 27 Aug 2010 21:50:19 -0500 Subject: Re: [Matplotlib-users] realtime plotting was working with matplotlib 0.99.1.1 and it doesn't with matplotlib 1.0.0 To: chiaracaro...@hotmail.com CC: matplotlib-users@lists.sourceforge.net On Fri, Aug 27, 2010 at 9:26 PM, Chiara Caronna wrote: Hi all, I have a script to update a plot in real time. It was working fine with matplotlib 0.99.1.1 but it doesn't work anymore with the new version. Here is the script: import numpy as n import pylab as p x=n.arange(10) y=n.random.randn(10) p.ion() fig=p.figure(1) ax=fig.add_subplot(111) line,=ax.plot(x,y,'ko-') for i in range(10): y=n.random.randn(10) line.set_data(x,y) p.draw() it is updating the plot correctly with matplotlib 0.99.1.1 when I run it with matplotlib 1.0.0 it doesn't show any picture at all Interestingly, if I add a line raw_input('ok') then it shows the plot and it updates it inside the loop x=n.arange(10) y=n.random.randn(10) p.ion() fig=p.figure(1) ax=fig.add_subplot(111) line,=ax.plot(x,y,'ko-') raw_input('ok?') for i in range(10): y=n.random.randn(10) line.set_data(x,y) p.draw() raw_input('ok?') Any idea why it is doing this? Is it a bug or am I missing something? Thanks for your help, Chiara It seems to work fine for me using the GTKAgg backend. Which backend are you using? Also, admittedly, this is the trunk build, so it might have some fixes that weren't in the release. Ben Root -- Sell apps to millions through the Intel(R) Atom(Tm) Developer Program Be part of this innovative community and reach millions of netbook users worldwide. Take advantage of special opportunities to increase revenue and speed time-to-market. Join now, and jumpstart your future. http://p.sf.net/sfu/intel-atom-d2d___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] realtime plotting was working with matplotlib 0.99.1.1 and it doesn't with matplotlib 1.0.0
Ok, it is a backend issue: I checked and I was using Qt4Agg as soon as I changed to TkAgg the script worked fine... still is this normal or is it a bug? thanks for your suggestion and help! Chiara From: chiaracaro...@hotmail.com To: ben.r...@ou.edu Date: Sat, 28 Aug 2010 03:01:54 + CC: matplotlib-users@lists.sourceforge.net Subject: Re: [Matplotlib-users] realtime plotting was working with matplotlib 0.99.1.1 and it doesn't with matplotlib 1.0.0 I think I am using TkAgg but I am not sure, how can I check it? From: ben.r...@ou.edu Date: Fri, 27 Aug 2010 21:50:19 -0500 Subject: Re: [Matplotlib-users] realtime plotting was working with matplotlib 0.99.1.1 and it doesn't with matplotlib 1.0.0 To: chiaracaro...@hotmail.com CC: matplotlib-users@lists.sourceforge.net On Fri, Aug 27, 2010 at 9:26 PM, Chiara Caronna wrote: Hi all, I have a script to update a plot in real time. It was working fine with matplotlib 0.99.1.1 but it doesn't work anymore with the new version. Here is the script: import numpy as n import pylab as p x=n.arange(10) y=n.random.randn(10) p.ion() fig=p.figure(1) ax=fig.add_subplot(111) line,=ax.plot(x,y,'ko-') for i in range(10): y=n.random.randn(10) line.set_data(x,y) p.draw() it is updating the plot correctly with matplotlib 0.99.1.1 when I run it with matplotlib 1.0.0 it doesn't show any picture at all Interestingly, if I add a line raw_input('ok') then it shows the plot and it updates it inside the loop x=n.arange(10) y=n.random.randn(10) p.ion() fig=p.figure(1) ax=fig.add_subplot(111) line,=ax.plot(x,y,'ko-') raw_input('ok?') for i in range(10): y=n.random.randn(10) line.set_data(x,y) p.draw() raw_input('ok?') Any idea why it is doing this? Is it a bug or am I missing something? Thanks for your help, Chiara It seems to work fine for me using the GTKAgg backend. Which backend are you using? Also, admittedly, this is the trunk build, so it might have some fixes that weren't in the release. Ben Root -- Sell apps to millions through the Intel(R) Atom(Tm) Developer Program Be part of this innovative community and reach millions of netbook users worldwide. Take advantage of special opportunities to increase revenue and speed time-to-market. Join now, and jumpstart your future. http://p.sf.net/sfu/intel-atom-d2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Sell apps to millions through the Intel(R) Atom(Tm) Developer Program Be part of this innovative community and reach millions of netbook users worldwide. Take advantage of special opportunities to increase revenue and speed time-to-market. Join now, and jumpstart your future. http://p.sf.net/sfu/intel-atom-d2d___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] problem with show()
I, I have a problem with showing plot. When I run this code: figure(1) semilogx(data[:,0],data[:,1]) savefig('try.png') show() It save the plot properly, but it doesn't show it. I tried to run it with "--verbose-helpful" and this is the output: matplotlib data path /usr/local/lib/python2.4/site-packages/matplotlib/mpl-data $HOME=/users/caronna CONFIGDIR=/users/caronna/.matplotlib loaded rc file /usr/local/lib/python2.4/site-packages/matplotlib/mpl-data/matplotlibrc matplotlib version 0.87.7 verbose.level helpful interactive is False platform is linux2 numerix numpy 1.0.1 font search path ['/usr/local/lib/python2.4/site-packages/matplotlib/mpl-data'] loaded ttfcache file /users/caronna/.matplotlib/ttffont.cache backend Agg version v2.2 Does anyone know what's the problem? Thanks, Chiara - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] newbie: easy question (I hope)
Hello, I would like to plot some data while the interpreter continues calculating... if I just write plot(x,y) show() Then the code stops until I close the window... how should I do? Thanks in advance Chiara _ Don't just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/ - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] backends issue
I have a problem with backend: by default it was Agg; i tried to change the file .matplotlibrc and to put GTKAgg, but as I import pylab I got these errors: >>>from pylab import * Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.4/site-packages/pylab.py", line 1, in ? from matplotlib.pylab import * File "/usr/local/lib/python2.4/site-packages/matplotlib/pylab.py", line 220, in ? new_figure_manager, draw_if_interactive, show = pylab_setup() File "/usr/local/lib/python2.4/site-packages/matplotlib/backends/__init__.py", line 23, in pylab_setup globals(),locals(),[backend_name]) File "/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in ? from backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\ File "/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_gtk.py", line 6, in ? import gobject ImportError: No module named gobject What can I do? Thanks. Chiara _ FREE pop-up blocking with the new MSN Toolbar - get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/ - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Polygon masking possible?
Hello, I am also interested in masking polygons and defining the polygon by 'clicking' on the image... but I do not know anything about GUI does anyone can help? Is there already something implemented? Thanks! Chiara > Date: Wed, 23 Jan 2008 13:50:15 +1300 > From: [EMAIL PROTECTED] > To: matplotlib-users@lists.sourceforge.net > Subject: Re: [Matplotlib-users] Polygon masking possible? > > Hi Søren, > > I've put this back on the list in case it's useful to anyone else, or > if there are better suggestions or improvements around. Hope you don't > mind. > > On 22/01/2008, Søren Nielsen <[EMAIL PROTECTED]> wrote: > > Yeah i'd like to see your code if I can.. > > import numpy as n > > def get_poly_pts(x, y, shape): > """Creates convex polygon mask from list of corners. > > Parameters > -- > x : array_like > x co-ordinates of corners > y : array_like > y co-ordinates of corners, in order corresponding to x > shape : array_like > dimension sizes of result > > Returns > --- > build : ndarray > 2-D array of shape shape with values True inside polygon > > Notes > - > Code is constrained to convex polygons by "inside" > assessment criterion. > > """ > x = n.asarray(x) > y = n.asarray(y) > shape = n.asarray(shape) > npts = x.size # should probably assert x.size == y.size > inds = n.indices( shape ) > xs = inds[0] > ys = inds[1] > xav = n.round(x.mean()).astype(int) > yav = n.round(y.mean()).astype(int) > for i in xrange(npts): # iterate over pairs of co-ordinates > j = (i + 1) % npts > m = (y[j] - y[i])/(x[j] - x[i]) > c = (x[j] * y[i] - x[i] * y[j])/(x[j] - x[i]) > thisone = ( ys > m * xs + c ) > if thisone[xav, yav] == False: > thisone = ~thisone > if i == 0: > build = thisone > else: > build &= thisone > return build > > (released under BSD licence) > > > I just needed the push over the edge to know how to draw on the canvas, > > mapping clicks etc. since i'm still fairly new to matplotlib, so I think > > your code will be helpfull. > > I hope so. As you can see this code doesn't do any of the drawing or > click collecting, but the cookbook page should be able to guide you > there. Ask again on the list if you have any further questions and > we'll see if we can help. > > Also, the code assumes that the average co-ordinate is inside the > shape - that's true for convex polygons, but not necessarily for > arbitrary ones. I use if after taking a convex hull of a greater list > of points (using the delaunay module in scipy (now in scikits, I > hear)), which ensures convexity. You just need to be aware of that > limitation. > > Cheers, > > A. > -- > AJC McMorland, PhD candidate > Physiology, University of Auckland > > - > 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 _ Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Polygon masking possible?
Hi, I tried ds9 and It looks like this is what I would like to do (though I couldn't try funtools, but what you describe is good). DO you think it is possible to make something like this with matplotlib? Thanks a lot for your help, Chiara > Date: Wed, 12 Mar 2008 02:55:55 -0400 > From: [EMAIL PROTECTED] > To: [EMAIL PROTECTED] > Subject: Re: [Matplotlib-users] Polygon masking possible? > CC: matplotlib-users@lists.sourceforge.net > > Hi, > > I often do this with ds9 and funtools. > ds9 is an astronomy-oriented image viewer (http://hea-www.harvard.edu/RD/ds9/) > but you can also use it with numpy array. > Within ds9, you can define regions (ellipse, polynomial, etc) easily > with a mouse. > After you define a region (and save it as a file), you can convert it > to a mask image > with funtools (funtools is a name of an astronomy-oriented image > utility pacakge). > funtools only support fits file (image format in astronomy) so this > can be a bit tricky, but if you're > interested i'll send my python wrapper code for it. > > So, take a look at ds9 and see it fits your need. > To view numpy array in ds9, > *. From python, save the array as a file (tofile method, better use > "arr" as an extension) > * in ds9, file-> open others -> open array. You need to select > array dimension, type and endianness of the array. > > Regards, > > -JJ > > > > > > On Sat, Mar 8, 2008 at 11:17 AM, Chiara Caronna > <[EMAIL PROTECTED]> wrote: > > > > Hello, > > I am also interested in masking polygons and defining the polygon by > > 'clicking' on the image... but I do not know anything about GUI does > > anyone can help? Is there already something implemented? > > Thanks! > > Chiara > > > > > Date: Wed, 23 Jan 2008 13:50:15 +1300 > > > From: [EMAIL PROTECTED] > > > To: matplotlib-users@lists.sourceforge.net > > > Subject: Re: [Matplotlib-users] Polygon masking possible? > > > > > > > > > > Hi Søren, > > > > > > I've put this back on the list in case it's useful to anyone else, or > > > if there are better suggestions or improvements around. Hope you don't > > > mind. > > > > > > On 22/01/2008, Søren Nielsen <[EMAIL PROTECTED]> wrote: > > > > Yeah i'd like to see your code if I can.. > > > > > > import numpy as n > > > > > > def get_poly_pts(x, y, shape): > > > """Creates convex polygon mask from list of corners. > > > > > > Parameters > > > -- > > > x : array_like > > > x co-ordinates of corners > > > y : array_like > > > y co-ordinates of corners, in order corresponding to x > > > shape : array_like > > > dimension sizes of result > > > > > > Returns > > > --- > > > build : ndarray > > > 2-D array of shape shape with values True inside polygon > > > > > > Notes > > > - > > > Code is constrained to convex polygons by "inside" > > > assessment criterion. > > > > > > """ > > > x = n.asarray(x) > > > y = n.asarray(y) > > > shape = n.asarray(shape) > > > npts = x.size # should probably assert x.size == y.size > > > inds = n.indices( shape ) > > > xs = inds[0] > > > ys = inds[1] > > > xav = n.round(x.mean()).astype(int) > > > yav = n.round(y.mean()).astype(int) > > > for i in xrange(npts): # iterate over pairs of co-ordinates > > > j = (i + 1) % npts > > > m = (y[j] - y[i])/(x[j] - x[i]) > > > c = (x[j] * y[i] - x[i] * y[j])/(x[j] - x[i]) > > > thisone = ( ys > m * xs + c ) > > > if thisone[xav, yav] == False: > > > thisone = ~thisone > > > if i == 0: > > > build = thisone > > > else: > > > build &= thisone > > > return build > > > > > > (released under BSD licence) > > > > > > > I just needed the push over the edge to know how to draw on the canvas, > > > > mapping clicks etc. since i'm still fairly new to matplotlib, so I think > > > > your code will be helpfull. > > > > > > I hope so. As you can see this code doesn't do any of the drawing or > > > click collecting, but the cookbook page should be able to guide you > > > there. Ask again on the list if you have any further questions and > > > we'll see if we can help. > >
Re: [Matplotlib-users] Polygon masking possible?
I am not sure how should I use it any hints? > From: [EMAIL PROTECTED] > To: matplotlib-users@lists.sourceforge.net > Subject: Re: [Matplotlib-users] Polygon masking possible? > Date: Fri, 14 Mar 2008 18:03:13 + > CC: [EMAIL PROTECTED] > > On Friday 14 March 2008 16:44:54 Chiara Caronna wrote: >> I tried ds9 and It looks like this is what I would like to do (though I >> couldn't try funtools, but what you describe is good). DO you think it is >> possible to make something like this with matplotlib? Thanks a lot for your > > The initiating thread (from January) had some suggestions. In particular, > some > code that does this from Rob Hetland: > > > Hope that helps, > Jose _ Discover the new Windows Vista http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] changing ticklabels color
Hello, I would like to change the color of the yticklabels. I tried to use this command: ax1=p.subplot(212) ax1.set_xlabel('t [sec]') ax1.set_ylabel('g^2(q,t)') ax1.set_yticklabels(color='r') but it gives an error: TypeError: set_yticklabels() takes at least 2 non-keyword arguments (1 given) if I write instead ax1.set_yticklabels(['1','2'],color='r') it works, but it puts clearly labels 1 and 2... I don't want to change the labels, only the color! is there anyway of doing it? Hope you can help me Chiara > Date: Thu, 22 May 2008 14:52:13 +0200 > From: [EMAIL PROTECTED] > To: matplotlib-users@lists.sourceforge.net > Subject: [Matplotlib-users] Legend labels - interaction with functions > > This is probably my lack of knowledge of python, but how do I set up > legend labels for some bar-plots that have been produced inside a > function. For example, the following will nicely plot my bar-plots, but > then legend doesn't know about the colours used, so here just uses black > for both labels. I'd like the labels to have the same colour as the bars > generated inside plotb. (I am using a function here as my real code has > extra stuff to calculate error-bars and suchlike for each data set.) > > x=arange(0,5) > y=array([ 1.2, 3.4, 5.4, 2.3, 1.0]) > z=array([ 2.2, 0.7, 0.4, 1.3, 1.2]) > > def plotb(x,y,col): > p=bar(x,y,color=col) > > plotb(x,y,'k') > plotb(x+0.4,z,'y') > > legend(('YYY,'ZZZ')) > > > I tried passing the object "p" through the plotb argument list, but > python didn't like that. (I am just learning python, and so far haven't > seen how to pass such objects around. > > Thanks for any tips, > > Dave > > - > 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 _ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] changing ticklabels color
> p.setp(ax1.get_yticklabels(), color='r') This worked! Thanks a lot! Chiara > To: matplotlib-users@lists.sourceforge.net > From: [EMAIL PROTECTED] > Date: Thu, 22 May 2008 17:52:09 +0300 > Subject: Re: [Matplotlib-users] changing ticklabels color > > Chiara Caronna <[EMAIL PROTECTED]> writes: > > > ax1=p.subplot(212) > > ax1.set_xlabel('t [sec]') > > ax1.set_ylabel('g^2(q,t)') > > ax1.set_yticklabels(color='r') > > You could do > > for label in ax1.get_yticklabels(): label.set_color('r') > > or use the setp shortcut: > > p.setp(ax1.get_yticklabels(), color='r') > > -- > Jouni K. Seppänen > http://www.iki.fi/jks > > > - > 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 _ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us- 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