Re: [Matplotlib-users] New contourf() drawing polygon boundaries for some reason?
I can't reproduce this error with the current code in SVN trunk, but I remember seeing this bug a while ago. So I'm guessing that this bug has already been fixed in SVN. Zane, could you try installing the latest matplotlib from trunk and see if you still see this bug? --Michiel --- On Mon, 6/15/09, Michael Droettboom md...@stsci.edu wrote: From: Michael Droettboom md...@stsci.edu Subject: Re: [Matplotlib-users] New contourf() drawing polygon boundaries for some reason? To: z...@amateurearthling.org, matplotlib-users matplotlib-users@lists.sourceforge.net, Michiel de Hoon mjldeh...@yahoo.com Date: Monday, June 15, 2009, 6:08 PM Thanks for the thorough investigation. Michiel: can you look into why the macosx backend is drawing the strokes around the polygons? Probably as simple as inadvertently ignoring an argument. I'll look into the path simplification-related issues. Cheers, Mike On 06/15/2009 03:29 PM, Zane Selvans wrote: Yes. By far the worst of these behaviors is the macosx GUI output. I could see the other ones just being the way it's supposed to look. Here's a summary: backend: macosx; path.simplify: (false|true) GUI = black borders to drawn polygons (incl. contour region crossing lines, very bad) http://zaneselvans.org/dropbox/contourf_backendmacosx.png backend: agg (PNG output) path.simplify: (true|false) = somewhat visible borders between polygons (esp. adjacent to contrasting colors) http://zaneselvans.org/dropbox/contourf_simplifytrue.png http://zaneselvans.org/dropbox/contourf_simplifyfalse.png backend: pdf (PDF output) path.simplify: true = reliably visible irregularities (but probably this is somewhat expected with SVG output) http://zaneselvans.org/dropbox/contourf_simplifytrue.pdf backend: pdf (PDF output) path.simplify: false = infinitessimally thin lines of background color visible between contour filled regions. http://zaneselvans.org/dropbox/contourf_simplifyfalse.pdf And here's what I used to generate them: def broken_contourf(): Simple demonstration that filled contour plots are broken. Looking at the PDF and PNG output using the macosx backend, everything is fine. It's only the GUI output which is for some reason outlining the polygons in the filled contours. from numpy.random import uniform, seed from matplotlib.mlab import griddata import matplotlib.pyplot as plt import numpy as np # make up data. #npts = int(raw_input('enter # of random points to plot:')) seed(-1) npts = 200 x = uniform(-2,2,npts) y = uniform(-2,2,npts) z = x*np.exp(-x**2-y**2) # define grid. xi = np.linspace(-2.1,2.1,100) yi = np.linspace(-2.1,2.1,100) # grid the data. zi = griddata(x,y,z,xi,yi) # contour the gridded data, plotting dots at the nonuniform data points. CS = plt.contourf(xi,yi,zi,15,cmap=plt.cm.jet) # plot data points. plt.title('griddata() and contourf() test') plt.savefig('broken_contourf.pdf') plt.savefig('broken_contourf.png') On Fri, Jun 12, 2009 at 3:02 PM, Zane Selvansz...@ideotrope.org wrote: I switched back to using the macosx backend, and it turns out that the thin black lines surrounding the polygons (including crossing the filled contour regions from one closed contour to another) only get displayed in the GUI. PDF and PNG output look fine. Zane On Fri, Jun 12, 2009 at 2:27 PM, Zane Selvansz...@ideotrope.org wrote: If I set path.simplify: False, the shape of the gaps between the filled polygons does change. Instead of being irregular, it becomes an infinitessimally thin gap of uniform width, allowing the (in this case white) background to show through. In both of these cases (path.simplify: True|False), the PNG version of the same figures also show representations of these gaps which are identical to those which appear in the PDF (though obviously pixelated), so I don't think it's something that's wrong in the vector graphics code per se. Zane On Fri, Jun 12, 2009 at 11:46 AM, Michael Droettboommd...@stsci.edu wrote: Shot in the dark here, but what if you set the rcParam path.simplify to False? There have been recent changes to that code. Also, since the Agg backend doesn't have an associated GUI, you need to use the savefig() command and provide a filename, rather than using show(). Cheers, Mike Zane Selvans wrote: Um, yeah. So my response got bounced because of the attachment. Take 2: For some reason my script bombed when I switched to the Agg backend, trying to display to the screen (it said Figure has no method show()) So I output the plot as both a PDF and a PNG (still having backend: agg in my rcfile) and in both of those cases, irregular gaps are visible
[Matplotlib-users] dynamic image update
Can someone point me to the best way to dynamically update a 2D [image] array (think of cellular automata)? E.g., this simple example works, but gets sluggish after several iterations: import numpy as N import pylab as P nx = 20 ny = 20 c = N.zeros(nx*ny, dtype='int8') c.resize(ny,nx) iters = 50 for its in range(iters): ix0 = N.random.rand()*nx iy0 = N.random.rand()*ny c[iy0,ix0] = 1 P.imshow(c,interpolation='nearest') P.draw() I'm guessing I'll want to use the mpl's API, but unsure of the best approach. I'm currently using mpl 0.98.5. thanks, Randy -- Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] dynamic image update
On Tue, Jun 16, 2009 at 11:42 AM, Randy Heilandheil...@indiana.edu wrote: Can someone point me to the best way to dynamically update a 2D [image] array (think of cellular automata)? E.g., this simple example works, but gets sluggish after several iterations: Use im.set_array rather than making multiple calls to imshow. See the dynamic_image* examples at http://matplotlib.sourceforge.net/examples/animation/index.html -- Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] trying to plot polar data
Hi I am running the following snippet ax = axes(polar=True) polar(angles,mag,'bo') and I get the attached plot How do make the dashed lines continue inward? How do choose the spacing? How do remove the ugly text? Mathew -- Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] beginner help: color map plot from raw data
I'm attempting to plot the distribution of bond angles in protein structures (the best-known example: http://en.wikipedia.org/wiki/Ramachandran_plot). I have the raw data as a collection of x,y,z data, where x and y are integers between -180 and 180, and z is a floating-point value. (Right now, this data is pure Python objects, but I can convert it to NumPy arrays if that would be easier.) I would like to plot this as a continuous color map inside a wxPython window, and also overlay the discreet data points for a separate protein. It doesn't really matter what combination of colors I use for this - there appear to be many built-in color maps that would be suitable. I'm pretty sure this is possible, based on looking at the examples, but I have no clue how to go about this - it doesn't help that all of the examples appear to use the pylab interface. Any suggestions? thanks, Nat -- Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] trying to plot polar data
Hi Mathew, On Tue, Jun 16, 2009 at 21:20, Yeates, Mathew Cmathew.c.yea...@jpl.nasa.gov wrote: Hi I am running the following snippet ax = axes(polar=True) polar(angles,mag,'bo') please include a full, working example: with this so few information we can help a little. and I get the attached plot no attached image. How do make the dashed lines continue inward? How do choose the spacing? How do remove the ugly text? could at least rgrids() thetagrids() help you in part of your questions? Regards, -- Sandro Tosi (aka morph, morpheus, matrixhasu) My website: http://matrixhasu.altervista.org/ Me at Debian: http://wiki.debian.org/SandroTosi -- Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] dynamic image update
On Tue, Jun 16, 2009 at 6:54 PM, John Hunterjdh2...@gmail.com wrote: On Tue, Jun 16, 2009 at 11:42 AM, Randy Heilandheil...@indiana.edu wrote: Can someone point me to the best way to dynamically update a 2D [image] array (think of cellular automata)? E.g., this simple example works, but gets sluggish after several iterations: Use im.set_array rather than making multiple calls to imshow. See the dynamic_image* examples at http://matplotlib.sourceforge.net/examples/animation/index.html Is there a similar function (to im.set_array) for graph plots ? - Sebastian -- Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Axes.frame vs. Axes.spines in SVN Basemap and Matplotlib? (was New contourf()...)
Yep, looks like the trunk has fixed the contourf() issue. Unfortunately there also seems to be some new incompatibility with the Basemap toolkit, even after re-installing Basemap from source. I get: AttributeError: Axes.frame was removed in favor of Axes.spines when I attempt to call: drawmapboundary(fill_color=white) Error output below: /Users/zane/svn/googlecode/satstress/satstress/nsrhist.pyc in makefigs(dbar_max, maps, hists, examples, stats, stress, tpw, lindensity, all, save_format) 774 if maps is True: #{{{2 775 print(Plotting Mapped Lineaments, fit to NSR stresses) -- 776 FitMap(nsrlins, nbins=9, titlestr=global lins, fit to NSR, dbar_max=dbar_max, outfile=figure_outfiles['FitMap_Mapped']) 777 print(Plotting Pre-TPW Lineaments, fit to NSR stresses) 778 FitMap(tpwlins, nbins=9, titlestr=pre-TPW lins, fit to NSR, dbar_max=dbar_max, outfile=figure_outfiles['FitMap_PreTPW']) /Users/zane/svn/googlecode/satstress/satstress/nsrhist.pyc in FitMap(lins, titlestr, lin_cm, nbins, stresscentric, outfile, dbar_max, showbad, derotate) 1005 linfitmap.drawmeridians(range(llcrnrlon,urcrnrlon+1,gridspace), labels=[1,0,0,1]) 1006 linfitmap.drawparallels(range(llcrnrlat,urcrnrlat+1,gridspace), labels=[1,0,0,1]) - 1007 linfitmap.drawmapboundary(fill_color=white) 1008 map_ax = fig.axes[0] 1009 /Library/Python/2.5/site-packages/mpl_toolkits/basemap/__init__.pyc in drawmapboundary(self, color, linewidth, fill_color, zorder, ax) 1263 else: # all other projections are rectangular. 1264 # use axesPatch for fill_color, frame for border line props. - 1265 ax.frame.set_linewidth(linewidth) 1266 if self.projection not in ['geos','ortho']: 1267 if fill_color is not None: /Library/Python/2.5/site-packages/matplotlib/axes.pyc in get_frame(self) 984 985 def get_frame(self): -- 986 raise AttributeError('Axes.frame was removed in favor of Axes.spines') 987 frame = property(get_frame) 988 AttributeError: Axes.frame was removed in favor of Axes.spines In [3]: import mpl_toolkits.basemap In [4]: mpl_toolkits.basemap.__version__ Out[4]: '0.99.4' On Tue, Jun 16, 2009 at 7:29 AM, Michiel de Hoonmjldeh...@yahoo.com wrote: I can't reproduce this error with the current code in SVN trunk, but I remember seeing this bug a while ago. So I'm guessing that this bug has already been fixed in SVN. Zane, could you try installing the latest matplotlib from trunk and see if you still see this bug? --Michiel --- On Mon, 6/15/09, Michael Droettboom md...@stsci.edu wrote: From: Michael Droettboom md...@stsci.edu Subject: Re: [Matplotlib-users] New contourf() drawing polygon boundaries for some reason? To: z...@amateurearthling.org, matplotlib-users matplotlib-users@lists.sourceforge.net, Michiel de Hoon mjldeh...@yahoo.com Date: Monday, June 15, 2009, 6:08 PM Thanks for the thorough investigation. Michiel: can you look into why the macosx backend is drawing the strokes around the polygons? Probably as simple as inadvertently ignoring an argument. I'll look into the path simplification-related issues. Cheers, Mike On 06/15/2009 03:29 PM, Zane Selvans wrote: Yes. By far the worst of these behaviors is the macosx GUI output. I could see the other ones just being the way it's supposed to look. Here's a summary: backend: macosx; path.simplify: (false|true) GUI = black borders to drawn polygons (incl. contour region crossing lines, very bad) http://zaneselvans.org/dropbox/contourf_backendmacosx.png backend: agg (PNG output) path.simplify: (true|false) = somewhat visible borders between polygons (esp. adjacent to contrasting colors) http://zaneselvans.org/dropbox/contourf_simplifytrue.png http://zaneselvans.org/dropbox/contourf_simplifyfalse.png backend: pdf (PDF output) path.simplify: true = reliably visible irregularities (but probably this is somewhat expected with SVG output) http://zaneselvans.org/dropbox/contourf_simplifytrue.pdf backend: pdf (PDF output) path.simplify: false = infinitessimally thin lines of background color visible between contour filled regions. http://zaneselvans.org/dropbox/contourf_simplifyfalse.pdf And here's what I used to generate them: def broken_contourf(): Simple demonstration that filled contour plots are broken. Looking at the PDF and PNG output using the macosx backend, everything is fine. It's only the GUI output which is for some reason outlining the polygons in the filled contours. from numpy.random import uniform, seed from matplotlib.mlab import griddata import matplotlib.pyplot as plt import numpy as np # make up data. #npts = int(raw_input('enter # of random points to plot:')) seed(-1) npts = 200 x = uniform(-2,2,npts) y = uniform(-2,2,npts)
Re: [Matplotlib-users] dynamic image update
On Tue, Jun 16, 2009 at 3:32 PM, Sebastian Haaseseb.ha...@gmail.com wrote: On Tue, Jun 16, 2009 at 6:54 PM, John Hunterjdh2...@gmail.com wrote: Is there a similar function (to im.set_array) for graph plots ? for lines you would use line.set_data (or set_ydata, set_xdata). Eg http://matplotlib.sourceforge.net/examples/animation/simple_anim_tkagg.html JDH -- Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] dynamic image update
On Tue, Jun 16, 2009 at 10:39 PM, John Hunterjdh2...@gmail.com wrote: On Tue, Jun 16, 2009 at 3:32 PM, Sebastian Haaseseb.ha...@gmail.com wrote: On Tue, Jun 16, 2009 at 6:54 PM, John Hunterjdh2...@gmail.com wrote: Is there a similar function (to im.set_array) for graph plots ? for lines you would use line.set_data (or set_ydata, set_xdata). Eg http://matplotlib.sourceforge.net/examples/animation/simple_anim_tkagg.html Thanks for the quick answer. This is obviously related to my post a few days ago -- a plotting benchmark ... What are the restrictions for the functions line.set_data or (assumingly similar) im.set_array ? E.g. must the size (shape) of the data remain unchanged ? Also, is there a performance difference if interactive mode is on or off ? - Sebastian -- Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Axes.frame vs. Axes.spines in SVN Basemap and Matplotlib? (was New contourf()...)
Zane Selvans wrote: Yep, looks like the trunk has fixed the contourf() issue. Unfortunately there also seems to be some new incompatibility with the Basemap toolkit, even after re-installing Basemap from source. I get: AttributeError: Axes.frame was removed in favor of Axes.spines It appears Basemap hasn't caught up with the new Axes.spines usage. Can you change mpl_toolkits/basemap/__init__.py line 1265 from:: ax.frame.set_linewidth(linewidth) to:: for spine in ax.spines.itervalues(): spine.set_linewidth(linewidth) There may be more issues, here -- this is just the first one and based off your traceback. Jeff: I had to drop the Axes.frame to implement spines that could be moved relative to the Axes boundary. I made sure this worked with the custom projection examples in the main MPL distribution, so I imagine it won't take too much to convert basemap. Please see svn r7144, 7145, and 7170 for my changes to lib/matplotlib/projections/geo.py -Andrew -- Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Axes.frame vs. Axes.spines in SVN Basemap and Matplotlib? (was New contourf()...)
Andrew Straw wrote: Zane Selvans wrote: Yep, looks like the trunk has fixed the contourf() issue. Unfortunately there also seems to be some new incompatibility with the Basemap toolkit, even after re-installing Basemap from source. I get: AttributeError: Axes.frame was removed in favor of Axes.spines It appears Basemap hasn't caught up with the new Axes.spines usage. Can you change mpl_toolkits/basemap/__init__.py line 1265 from:: ax.frame.set_linewidth(linewidth) to:: for spine in ax.spines.itervalues(): spine.set_linewidth(linewidth) There may be more issues, here -- this is just the first one and based off your traceback. Jeff: I had to drop the Axes.frame to implement spines that could be moved relative to the Axes boundary. I made sure this worked with the custom projection examples in the main MPL distribution, so I imagine it won't take too much to convert basemap. Please see svn r7144, 7145, and 7170 for my changes to lib/matplotlib/projections/geo.py -Andrew Andrew: This is now fixed in SVN. BTW: basemap predates the custom projection support in matplotlib, so it actually doesn't use it. -Jeff -- Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users