[Matplotlib-users] does mpl.canvas has a flag needsdrawing?
I have multiple canvas and sometimes one or more might have nothing to draw (no data). Currently I just call. canvas.draw() canvas.Refresh() for each of the canvas, but this gives me an error if there is no data. Is there a built-in flag I can check before calling draw? Or do I have to keep create my own? Werner PS If it is of any help, I get this (also I have mpl.verbose.level = u'silent': C:\Python25\lib\site-packages\matplotlib\axes.py:3996: UserWarning: No labeled objects found. Use label='...' kwarg on individual plots. warnings.warn(No labeled objects found. And here is the traceback. Traceback (most recent call last): File C:\Dev\twcbBranchv31\Program\panelstats.py, line 178, in DoRefresh self.RefreshAllGraphs() File C:\Dev\twcbBranchv31\Program\panelstats.py, line 313, in RefreshAllGraphs self.priceChangeP.canvas.draw() File C:\Python25\Lib\site-packages\matplotlib\backends\backend_wxagg.py, line 59, in draw FigureCanvasAgg.draw(self) File C:\Python25\Lib\site-packages\matplotlib\backends\backend_agg.py, line 314, in draw self.figure.draw(self.renderer) File C:\Python25\Lib\site-packages\matplotlib\artist.py, line 46, in draw_wrapper draw(artist, renderer, *kl) File C:\Python25\Lib\site-packages\matplotlib\figure.py, line 774, in draw for a in self.axes: a.draw(renderer) File C:\Python25\Lib\site-packages\matplotlib\artist.py, line 46, in draw_wrapper draw(artist, renderer, *kl) File C:\Python25\Lib\site-packages\matplotlib\axes.py, line 1721, in draw a.draw(renderer) File C:\Python25\Lib\site-packages\matplotlib\artist.py, line 46, in draw_wrapper draw(artist, renderer, *kl) File C:\Python25\Lib\site-packages\matplotlib\axis.py, line 736, in draw for tick, loc, label in self.iter_ticks(): File C:\Python25\Lib\site-packages\matplotlib\axis.py, line 677, in iter_ticks majorLocs = self.major.locator() File C:\Python25\Lib\site-packages\matplotlib\dates.py, line 754, in __call__ dmin, dmax = self.viewlim_to_dt() File C:\Python25\Lib\site-packages\matplotlib\dates.py, line 454, in viewlim_to_dt return num2date(vmin, self.tz), num2date(vmax, self.tz) File C:\Python25\Lib\site-packages\matplotlib\dates.py, line 249, in num2date if not cbook.iterable(x): return _from_ordinalf(x, tz) File C:\Python25\Lib\site-packages\matplotlib\dates.py, line 170, in _from_ordinalf dt = datetime.datetime.fromordinal(ix) ValueError: ordinal must be = 1 -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] axes3d material in matplotlib-0.99.0.win32-py2.5 missing?
On Thu, Sep 17, 2009 at 8:34 PM, Reckoner recko...@gmail.com wrote: thanks. does this mean that http://www.scipy.org/Cookbook/Matplotlib/mplot3D is out of date? Yes, it needs to be updated -- best would just be to remove the contents there and point to the mplot3d on the mpl website. Can you do this for us? JDH -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] does mpl.canvas has a flag needsdrawing?
On Fri, Sep 18, 2009 at 4:39 AM, Werner F. Bruhin werner.bru...@free.fr wrote: I have multiple canvas and sometimes one or more might have nothing to draw (no data). Currently I just call. canvas.draw() canvas.Refresh() for each of the canvas, but this gives me an error if there is no data. Is there a built-in flag I can check before calling draw? Or do I have to keep create my own? There is no such flag, but you should not get an error on drawing an empty figure or one that doesn't need to be drawn. Can you post example code that produces the error? JDH -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] violin plots
On Thu, Sep 17, 2009 at 11:28 PM, Andrew Straw straw...@astraw.com wrote: Flávio Coelho has implemented Violin plots for MPL. Nice! He has a question regarding its suitability for inclusion due to a dependency on scipy for the gaussian_kde function. http://pyinsci.blogspot.com/2009/09/violin-plot-with-matplotlib.html Is there a place this could live in the MPL code base without requiring scipy? Perhaps we should just include it as a demo. I note that examples/pylab_examples/demo_agg_filter.py requires scipy, too. Thanks Flávio for sharing -- I have occasionally wondered how my data would look in a violin plot. These do look nice, and the implementation is fairly light. I don't have strong feelings about what the best way to include this is: * as an example * as a proper mpl pyplot/axes function that imports scipy internally and raises if it can't find it * that requires a kde to be passed in Of these, the top two are probably preferable since in practice everyone would just pass in the kde from scipy so why not just save them the step and try to import it ourselves. While I don't want the core of mpl to require scipy, I can certainly abide by some functions requiring it as long as they raise helpful errors. So I'm leaning towards the 2nd option (we already do something like this -- we conditionally import Image in imread for example) If we go that way, we will have the worry about version dependencies and what we want to require on the buildbots. As for a patch, the implementation looks good though we need a better docstring and one that is Sphinx compliant. One thing you will want to consider is how to support the boxplot and fill between keywords. Eg, people will want to customize the fills, so you may want something like violin_plot(blah, fillprops=None, boxprops=None): if fillprops is None: fillprops = dict(facecolor='yellow', alpha=0.3) if boxprops is None: boxprops = dict(notch=1, vert=1) ax.fill_betweenx(blahblah, **fillprops) etc... that way people can sti In you docstring, you should also point to the fill_betweenx and boxprops docs using the Sphinx API conventions. Finally, we will need a pass-through interface in pyplot, most likely through a boilerplate.py entry, and a unit test :-) Some of this is discussed at http://matplotlib.sourceforge.net/devel/coding_guide.html, but some of these conventions are undocumented, so we're happy to help with any part that is confusing. JDH -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] does mpl.canvas has a flag needsdrawing?
We want a complete, free standing example that exposes the bug, with any additional info like mpl backend and version number. On Sep 18, 2009, at 7:43 AM, Werner F. Bruhin werner.bru...@free.fr wrote: John, John Hunter wrote: On Fri, Sep 18, 2009 at 4:39 AM, Werner F. Bruhin werner.bru...@free.fr wrote: I have multiple canvas and sometimes one or more might have nothing to draw (no data). Currently I just call. canvas.draw() canvas.Refresh() for each of the canvas, but this gives me an error if there is no data. Is there a built-in flag I can check before calling draw? Or do I have to keep create my own? There is no such flag, but you should not get an error on drawing an empty figure or one that doesn't need to be drawn. Can you post example code that produces the error? I narrowed it down to one line of code, if I comment the following line then the error goes away. axes.xaxis.set_major_formatter(yearFmt) Is this enough for you? Or do you like some runnable code? Werner --- --- --- - Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] does mpl.canvas has a flag needsdrawing?
John, John Hunter wrote: On Fri, Sep 18, 2009 at 4:39 AM, Werner F. Bruhin werner.bru...@free.fr wrote: I have multiple canvas and sometimes one or more might have nothing to draw (no data). Currently I just call. canvas.draw() canvas.Refresh() for each of the canvas, but this gives me an error if there is no data. Is there a built-in flag I can check before calling draw? Or do I have to keep create my own? There is no such flag, but you should not get an error on drawing an empty figure or one that doesn't need to be drawn. Can you post example code that produces the error? I narrowed it down to one line of code, if I comment the following line then the error goes away. axes.xaxis.set_major_formatter(yearFmt) Is this enough for you? Or do you like some runnable code? Werner -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] does mpl.canvas has a flag needsdrawing?
John Hunter wrote: We want a complete, free standing example that exposes the bug, with any additional info like mpl backend and version number. matplotlib: 0.99.0 wx.Python: 2.8.10.1 (unicode on Win Vista) Python 2.5.4 If I comment line 78 then the exception goes away. The attached code does not use, but the exception is the same as I get in my code when I call draw. Hope this helps Werner On Sep 18, 2009, at 7:43 AM, Werner F. Bruhin werner.bru...@free.fr wrote: John, John Hunter wrote: On Fri, Sep 18, 2009 at 4:39 AM, Werner F. Bruhin werner.bru...@free.fr wrote: I have multiple canvas and sometimes one or more might have nothing to draw (no data). Currently I just call. canvas.draw() canvas.Refresh() for each of the canvas, but this gives me an error if there is no data. Is there a built-in flag I can check before calling draw? Or do I have to keep create my own? There is no such flag, but you should not get an error on drawing an empty figure or one that doesn't need to be drawn. Can you post example code that produces the error? I narrowed it down to one line of code, if I comment the following line then the error goes away. axes.xaxis.set_major_formatter(yearFmt) Is this enough for you? Or do you like some runnable code? Werner -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users # -*- coding: utf-8 -*-# #!/usr/bin/env python An example of how to use wx or wxagg in an application with the new toolbar - comment out the setA_toolbar line for no toolbar import datetime from numpy import arange, sin, pi import matplotlib print matplotlib.__version__ # uncomment the following to use wx rather than wxagg #matplotlib.use('WX') #from matplotlib.backends.backend_wx import FigureCanvasWx as FigureCanvas # comment out the following to use wx rather than wxagg matplotlib.use('WXAgg') from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas from matplotlib.backends.backend_wx import NavigationToolbar2Wx from matplotlib.figure import Figure from matplotlib.dates import YearLocator, MonthLocator, DateFormatter, WeekdayLocator from matplotlib.dates import MONDAY, SATURDAY from matplotlib.finance import quotes_historical_yahoo import wx print wx.__version__ class CanvasFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self,None,-1, 'CanvasFrame',size=(550,350)) self.SetBackgroundColour(wx.NamedColor(WHITE)) self.figure = Figure() self.canvas = FigureCanvas( self, -1, self.figure) date1 = datetime.date( 2002, 1, 5 ) date2 = datetime.date( 2003, 12, 1 ) # every monday mondays = WeekdayLocator(MONDAY) # every 3rd month months= MonthLocator(range(1,13), bymonthday=1, interval=3) monthsFmt = DateFormatter(%b '%y) quotes = quotes_historical_yahoo('INTC', date1, date2) if not quotes: print 'Found no quotes' raise SystemExit dates = [q[0] for q in quotes] opens = [q[1] for q in quotes] self.axes = self.figure.add_subplot(111) # following line is commented to force the exception ##self.axes.plot_date(dates, opens, '-') self.axes.autoscale_view() self.axes.grid(True) yearLoc = YearLocator() yearFmt = DateFormatter('%Y') # comment the following line not to get the exeception self.axes.xaxis.set_major_formatter(yearFmt) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.SetSizer(self.sizer) self.Fit() self.add_toolbar() # comment this out for no toolbar def add_toolbar(self): self.toolbar = NavigationToolbar2Wx(self.canvas) self.toolbar.Realize() if wx.Platform == '__WXMAC__': # Mac platform (OSX 10.3, MacPython) does not seem to cope with # having a toolbar in a sizer. This work-around gets the buttons # back, but at the expense of having the toolbar at the top self.SetToolBar(self.toolbar) else: # On Windows platform, default window size is incorrect, so set # toolbar width to figure width. tw, th = self.toolbar.GetSizeTuple() fw, fh = self.canvas.GetSizeTuple() #
Re: [Matplotlib-users] does mpl.canvas has a flag needsdrawing?
On Fri, Sep 18, 2009 at 8:15 AM, Werner F. Bruhin werner.bru...@free.fr wrote: John Hunter wrote: We want a complete, free standing example that exposes the bug, with any additional info like mpl backend and version number. Thanks -- when posting a bug, please consider taking the time to make a *minimal* example. Ie, there is a lot of wx cruft in the example, as well as a lot of stuff that is created but not used (various tickers, locators and datetime instances). We have to then filter this down to the core bug to see if it is real. In this case it is. But we get 1000 emails a month in addition to having to work on normal mpl releases and development so we can use all the help we can get. Here is my version of a minimal example, tested and failing on the release branch and svn HEAD. I've filed a bug report at https://sourceforge.net/tracker/?func=detailaid=2861426group_id=80706atid=560720 and committed a unit test with a knownfailure decorator import matplotlib.dates as dates fig = plt.figure() ax = fig.add_subplot(111) yearFmt = dates.DateFormatter('%Y') ax.xaxis.set_major_formatter(yearFmt) fig.savefig('empty_date_bug') That much more clearly shows where the problem is, doesn't require a developer to have an optionaol backend installed, etc. Thanks for the report and the test case. JDH -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Contouring on triangular grids
I've written some code to perform contouring on triangular grids. I wrote the underlying C++ for a separate project, but as there has been some interest on the mpl mailing lists for such functionality I've had a go at wrapping it up as a python module so that it is available from mpl. I've also added a few utility functions for plotting triangular grids, doing pseudocolour plots, etc. Attached is the source code with some documentation and examples. There's an example of the output at http://img10.imageshack.us/img10/2873/tricontourfdemo3g.png This example is similar to one of the mpl contourf examples, but on a triangular grid of 1000 randomly spaced points, with the grid overlaid. So far it is only experimental code and hasn't been widely tested. I have a list of improvements already, but thought it best to let people see a working version before spending time polishing it. If it turned out that a (much improved) version of it was considered good enough to incorporate into mpl, I'd would happily help as I'd like to contribute. I hope someone finds it useful! Ian Thomas mpl_tri.tar.gz Description: GNU Zip compressed data -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Polar plots rendered incorrectly in SVG
Dear Jae-Joon, Your workaround worked perfectly! Thanks a lot! Cheers, Bartosz -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] does mpl.canvas has a flag needsdrawing?
My guess is that the error happens when the matplotlib tries to format the date ticklabels when the xlim is not correctly set, i.e., [0, 1] in the example. But, I'm not sure what is the best approach here. Werner, if there is nothing to draw (i,e, xlim is [0,1]), change the xlim to some arbitrary range that is greater than 1 (e.g, [1,2]). For example, in your code, you may do something like following after calling the autoscale_view(). self.axes.autoscale_view() if self.axes.get_xlim()[0] 1: self.axes.set_xlim(dates[0], dates[-1]) Regards, -JJ On Fri, Sep 18, 2009 at 11:41 AM, Werner F. Bruhin werner.bru...@free.fr wrote: John Hunter wrote: On Fri, Sep 18, 2009 at 8:15 AM, Werner F. Bruhin werner.bru...@free.fr wrote: John Hunter wrote: We want a complete, free standing example that exposes the bug, with any additional info like mpl backend and version number. Thanks -- when posting a bug, please consider taking the time to make a *minimal* example. Sorry about that - was a bit in a hurry, but that is no excuse! Will do better next time. Thanks for anyhow having taken the time to look at it and to distill it down. Werner -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Contouring on triangular grids
Ian Thomas wrote: I've written some code to perform contouring on triangular grids. I wrote the underlying C++ for a separate project, but as there has been some interest on the mpl mailing lists for such functionality I've had a go at wrapping it up as a python module so that it is available from mpl. I've also added a few utility functions for plotting triangular grids, doing pseudocolour plots, etc. Hi Ian, Thanks for this. I haven't had a chance to look at your code -- can you elaborate on the approach you took versus natural neighbors interpolation, as available through the mlab.griddata function? (See examples/pylab_examples/griddata_demo.py for an example apparently similar to yours.) -Andrew -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Contouring on triangular grids
Andrew Straw wrote: Thanks for this. Yes, indeed. It looks like nice stuff! I do encourage you to keep up the good work on this (the only thing I notice is the need for some more docs). I also encourage you to keep the contour generating code separate from anything matplotlib specific. I, for one, would like to use it outside of MPL. Unfortunately, it will probably be a month or two before I can spend any time digging into this for my stuff, but it looks great so far. I haven't had a chance to look at your code -- can you elaborate on the approach you took versus natural neighbors interpolation, as available through the mlab.griddata function? I think I can answer that a bit: this is contouring directly on the triangular mesh, rather than interpolating to a rectangular grid, then contouring. It should be a little more accurate, as well as saving processing time and memory. In particular, it should work better around the edges of a non-rectangular domain. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/ORR(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] saving an axes to draw in a different figure
I don't think your approach will work in general. When you move an axes from one figure to the other, you have to update the transform attributes of all the artists, which, I think, could be tricky to do for general cases. On Thu, Sep 17, 2009 at 1:59 PM, jason-s...@creativetrax.com wrote: I'm trying to draw the axes from one figure directly over the axes for another figure, in a sense, combining the two axes as two layers on one figure. So, first I get an axes instance, ax. import matplotlib.pyplot as plt fig=plt.figure() fig.add_subplot(111) plt.plot(range(10), [i^2 for i in range(10)]) ax=fig.axes[0] plt.savefig('test.png') Okay, now I have the axes ax. I want to draw ax directly on top of the following figure, and get a result that would be the same as if I had called the plot command above directly in the following code. All I'm passed in my real code is the newax variable below, which is why I use newax.get_figure()). fig=plt.figure() newax=fig.add_subplot(111) ax.set_figure(newax.get_figure()) newax.get_figure().add_axes(ax,label=newax) plt.savefig('test2.png') For this particular case, set the figure attribute directly instead of calling the set_figure methods, which does more extra stuff. For example, fig=plt.figure() ax.figure = fig fig.add_axes(ax,label=newax) plt.savefig('test2.png') At least you will have your ticks right. Again, this approach won't work well unless you update the transform of all the artists as well. However, the result of test2.png is not very pretty and definitely not what I want. The tick labels for the y-axis are all scrunched up, for example. Can anyone help? For those curious, what I'm doing is working on getting the Sage graphics code to be able to wrap and intelligently display matplotlib axes objects, so that a person could easily create a matplotlib axes, wrap it in the Sage graphics class, and then be able to manipulate it in Sage. In order for this to work, it seems like I need to save the axes object I care about, and then when Sage composes it's final figure (using matplotlib), it passes me an AxesSubplot object. I need to somehow take that subplot object and draw my saved axes on it in the most intelligent way possible. In the code above, I try taking the given AxesSubplot object, getting the figure from that, and then just adding my saved axes to that figure. Is there a better way to do this? Having never used Sage before, I have little idea what you want to do here (for example, what do you mean by Sage composes it's final figure?). Anyhow, I think it would be best if you can figure out some way that does not involves axes moving around. Regards, -JJ Thanks, Jason -- Jason Grout -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] saving an axes to draw in a different figure
On Fri, Sep 18, 2009 at 11:44 AM, Jae-Joon Lee lee.j.j...@gmail.com wrote: I don't think your approach will work in general. When you move an axes from one figure to the other, you have to update the transform attributes of all the artists, which, I think, could be tricky to do for general cases. I agree that this would be difficult with the existing code base, but it would be something that is nice to support. Perhaps we can think about adding support for a fig.move_axes_to(otherfig) method that reconnects all the wiring. We would of course have to be very careful about all the child artists, but this would be a good thing to get right. JDH -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] does mpl.canvas has a flag needsdrawing?
Hi Jae-Joon, Jae-Joon Lee wrote: My guess is that the error happens when the matplotlib tries to format the date ticklabels when the xlim is not correctly set, i.e., [0, 1] in the example. But, I'm not sure what is the best approach here. Werner, if there is nothing to draw (i,e, xlim is [0,1]), change the xlim to some arbitrary range that is greater than 1 (e.g, [1,2]). For example, in your code, you may do something like following after calling the autoscale_view(). Thanks for the tip. I have in the mean time reorganized my code and I am just bypassing the problematic code if there is nothing to draw. Werner -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] saving an axes to draw in a different figure
John Hunter wrote: On Fri, Sep 18, 2009 at 11:44 AM, Jae-Joon Lee lee.j.j...@gmail.com wrote: I don't think your approach will work in general. When you move an axes from one figure to the other, you have to update the transform attributes of all the artists, which, I think, could be tricky to do for general cases. I agree that this would be difficult with the existing code base, but it would be something that is nice to support. Perhaps we can think about adding support for a fig.move_axes_to(otherfig) method that reconnects all the wiring. We would of course have to be very careful about all the child artists, but this would be a good thing to get right. Okay. I was hoping that maybe you would say the right way to do this was using inset_axes or something (http://matplotlib.sourceforge.net/examples/axes_grid/inset_locator_demo.html), but I think I understand from the comments why, for example, the ticks were all off in my example. I guess we'll put this functionality in Sage on hold pending the functionality you mention above... Thanks, Jason -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matshow
On Thu, Sep 17, 2009 at 2:49 AM, Bala subramanian bala.biophys...@gmail.com wrote: Friends, I have a matrix data and i used matshow() function to plot. The plot is attached. 1) After plotting the data, i used xticks() function to change the x-axis tick labels from x1 to x12 ( figure attached). Similarly I want to change the y-axis tick labels into as A,B and C, instead of 0,1,2 (in the attached figure) but when i use yticks() function as below, it dosent happen, instead it changes the plot. yticks( arange(3), ('A','B','C')) Can you post a complete code (a simplified version that reproduces the problem)? I have done some simple tests but it worked as expected. Also, please report the version number of your mpl installation. 2) I used the colormap cm.autumn to create the plot. Suppose if i want to generate the same plot with green,black, red combination, how should i specify the colors in matshow. If none of the mpl's colormaps fits your need, you need to create your own colormap. Maybe the links below will be helpful. http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps -JJ Thanks in advance. Bala -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] matplotlib crashing on WxAgg backend
hello, have an error occuring that causes my app to crash. I found a few other email listings similar to my problem, but there were no responses that I could learn from. I am quickly plotting an array as it grows. I have a wxframe, canvas, figure and an axes. I clear the axes, plot the array, draw the canvas. this is happening at about 5 hz. I get the error message listed below and it only occurs when the mouse is hovering over the canvas or a button is pressed. I disabled these events from my canvas yet I still get this error, so I am not sure it is something from my code. If I am not doing all this fast redrawing. there is no problem, ie. if the image is static I don't have this error. I suspect it has something to do with the axes objects clearing and redrawing while a mouse or key event is simultaneously being drawn. Please advise as to how I may fix this problem. thanks for your help. Jeff Traceback (most recent call last): File C:\Python26\lib\site-packages\matplotlib\backends\backend_wx.py, line 1315, in _onMotion FigureCanvasBase.motion_notify_event(self, x, y, guiEvent=evt) File C:\Python26\lib\site-packages\matplotlib\backend_bases.py, line 1244, in motion_notify_event guiEvent=guiEvent) File C:\Python26\lib\site-packages\matplotlib\backend_bases.py, line 899, in __init__ LocationEvent.__init__(self, name, canvas, x, y, guiEvent=guiEvent) File C:\Python26\lib\site-packages\matplotlib\backend_bases.py, line 835, in __init__ self._update_enter_leave() File C:\Python26\lib\site-packages\matplotlib\backend_bases.py, line 844, in _update_enter_leave last.canvas.callbacks.process('axes_leave_event', last) File C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py, line 14568, in __getattr__ raise PyDeadObjectError(self.attrStr % self._name) wx._core.PyDeadObjectError: The C++ part of the Canvas object has been deleted, attribute access no longer allowed. -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] axes3d material in matplotlib-0.99.0.win32-py2.5 missing?
if you're asking me, I don't have write access to this website. Thanks again. On Fri, Sep 18, 2009 at 4:45 AM, John Hunter jdh2...@gmail.com wrote: On Thu, Sep 17, 2009 at 8:34 PM, Reckoner recko...@gmail.com wrote: thanks. does this mean that http://www.scipy.org/Cookbook/Matplotlib/mplot3D is out of date? Yes, it needs to be updated -- best would just be to remove the contents there and point to the mplot3d on the mpl website. Can you do this for us? JDH -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [xpyx] Re: axes3d material in matplotlib-0.99.0.win32-py2.5 missing?
On Fri, Sep 18, 2009 at 4:00 PM, Philip Austin paus...@eos.ubc.ca wrote: Reckoner wrote: if you're asking me, I don't have write access to this website. See http://www.scipy.org/UserPreferences to create a wiki account -- best, Phil I was asking you -- let me know if you are unable to do it and one of us can follow up. Thanks! JDH -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] How to plot saved plot data in a new figure?
Hi, Is there a standard way to compute first and then plot something later? For example, I would like to generate a fine contour plot, then use it as a background later. x = np.linspace(-1,1,1000) X,Y = np.meshgrid(x,x) Z = ((X*X + Y*Y) - 0.5)**2 + Y**2 contours = plt.contour(X,Y,Z,100) # Takes a while... del x, X, Y, Z I would like to the later plot the contours quickly. What is the proper way to do this in general? I can do something like the following, but it seems like a hack (and may be missing important connections: for example, I initially forgot to set the transform which meant that the data was disconnected from the axis scale...) f = plt.figure() ax = plt.gca() for collection in contours.collections: collection.set_transform(ax.transData) ax.add_collection(collection) ax.autoscale_view() plt.draw() Have I forgotten anything here? I would have expected that, for any plotting command, the return value could be passed to an axis command, something like f = plt.figure() ax = plt.gca() ax.add(contours) or maybe even ax.contour(contours) though a general function to take the object returned by a plot command and plot it on the current axis efficiently would be best. I can't find this functionality or a description about how to do this. Any suggestions? Likewise, is there an easy way to duplicate a figure (including the axes properties etc.) so one can produce two similar figures with slightly modified parameters? Thanks, Michael. -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] pyplot.show
Hi all, I am a beginner with matplotlib and doing my first steps with python plotting. However, I learned that pyplot.show really forces the display of already existing plots. For instance, when I type In[2]: pyplot.plot([1,2,3]) Out[2]: [matplotlib.lines.Line2D object at 0x2e33850] nothing happens until I type In[3]: pyplot.show() After that, the interpreter halts until I close the new figure window. Only closing enables the interpreter to continue with my later input. Moreover, typing In[4]: pyplot.plot([1,2,3]) again would display the figure immediately. Seems the gtk engine or something else must be started up by pyplot.show once and, once running, it displays everything else after that instantly. How can I tweak pyplot in such way that it would display my figures on the very first pyplot.plot call without halting the input? Thank you in advance for your help, Thomas -- View this message in context: http://www.nabble.com/pyplot.show-tp25518658p25518658.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] pyplot.show
may be you can try pyplot.ion()? it turns interactive mode on. Hope this helps. On Sat, Sep 19, 2009 at 1:11 PM, Thomas Hrabe thr...@gmail.com wrote: Hi all, I am a beginner with matplotlib and doing my first steps with python plotting. However, I learned that pyplot.show really forces the display of already existing plots. For instance, when I type In[2]: pyplot.plot([1,2,3]) Out[2]: [matplotlib.lines.Line2D object at 0x2e33850] nothing happens until I type In[3]: pyplot.show() After that, the interpreter halts until I close the new figure window. Only closing enables the interpreter to continue with my later input. Moreover, typing In[4]: pyplot.plot([1,2,3]) again would display the figure immediately. Seems the gtk engine or something else must be started up by pyplot.show once and, once running, it displays everything else after that instantly. How can I tweak pyplot in such way that it would display my figures on the very first pyplot.plot call without halting the input? Thank you in advance for your help, Thomas -- View this message in context: http://www.nabble.com/pyplot.show-tp25518658p25518658.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] pyplot.show
Hi, thank you for the quick reply. Unfortunately, none of both works for me. values = [1,2,3]; pyplot.ioff(); #pyplot.ion(); print pyplot.isinteractive(); pyplot.plot(values); pyplot.show(); The value (True|False) of interactive mode does not make a difference to the plotting. Other suggestionst? Thanks so far! may be you can try pyplot.ion()? it turns interactive mode on. Hope this helps. On Sat, Sep 19, 2009 at 1:11 PM, Thomas Hrabe thr...@gmail.com wrote: Hi all, I am a beginner with matplotlib and doing my first steps with python plotting. However, I learned that pyplot.show really forces the display of already existing plots. For instance, when I type In[2]: pyplot.plot([1,2,3]) Out[2]: [matplotlib.lines.Line2D object at 0x2e33850] nothing happens until I type In[3]: pyplot.show() After that, the interpreter halts until I close the new figure window. Only closing enables the interpreter to continue with my later input. Moreover, typing In[4]: pyplot.plot([1,2,3]) again would display the figure immediately. Seems the gtk engine or something else must be started up by pyplot.show once and, once running, it displays everything else after that instantly. How can I tweak pyplot in such way that it would display my figures on the very first pyplot.plot call without halting the input? Thank you in advance for your help, Thomas -- View this message in context: http://www.nabble.com/pyplot.show-tp25518658p25518658.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- View this message in context: http://www.nabble.com/pyplot.show-tp25518658p25518780.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] pyplot.show
Running IPython with -pylab or specifying the threading option? See more at http://ipython.scipy.org/doc/stable/html/interactive/reference.html?highlight=pylab On Sat, Sep 19, 2009 at 12:42 AM, Thomas Hrabe thr...@gmail.com wrote: Hi, thank you for the quick reply. Unfortunately, none of both works for me. values = [1,2,3]; pyplot.ioff(); #pyplot.ion(); print pyplot.isinteractive(); pyplot.plot(values); pyplot.show(); The value (True|False) of interactive mode does not make a difference to the plotting. Other suggestionst? Thanks so far! may be you can try pyplot.ion()? it turns interactive mode on. Hope this helps. On Sat, Sep 19, 2009 at 1:11 PM, Thomas Hrabe thr...@gmail.com wrote: Hi all, I am a beginner with matplotlib and doing my first steps with python plotting. However, I learned that pyplot.show really forces the display of already existing plots. For instance, when I type In[2]: pyplot.plot([1,2,3]) Out[2]: [matplotlib.lines.Line2D object at 0x2e33850] nothing happens until I type In[3]: pyplot.show() After that, the interpreter halts until I close the new figure window. Only closing enables the interpreter to continue with my later input. Moreover, typing In[4]: pyplot.plot([1,2,3]) again would display the figure immediately. Seems the gtk engine or something else must be started up by pyplot.show once and, once running, it displays everything else after that instantly. How can I tweak pyplot in such way that it would display my figures on the very first pyplot.plot call without halting the input? Thank you in advance for your help, Thomas -- View this message in context: http://www.nabble.com/pyplot.show-tp25518658p25518658.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- View this message in context: http://www.nabble.com/pyplot.show-tp25518658p25518780.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Gökhan -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users