[Matplotlib-users] contour_demo.py
Hi everybody, I'm trying to run contour_demo.pp example but I'm having this error. Anybody can help? Thanks, X Error: BadDevice, invalid or uninitialized input device 166 Major opcode: 144 Minor opcode: 3 Resource id: 0x0 Failed to open device X Error: BadDevice, invalid or uninitialized input device 166 Major opcode: 144 Minor opcode: 3 Resource id: 0x0 Failed to open device [-0.8666166 ,-0.49865195,-0.13068729, 0.23727736, 0.60524202, 0.97320667, 1.34117133,] type: type 'array' ['__copy__', '__deepcopy__', 'astype', 'byteswapped', 'copy', 'iscontiguous', 'itemsize', 'resize', 'savespace', 'spacesaver', 'tolist', 'toscalar', 'tostring', 'typecode'] * * * * * * * * * * a list of 7 LineCollection objects type: class 'matplotlib.cbook.silent_list' ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__dict__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__module__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__str__', '__weakref__', 'append', 'count', 'extend', 'index', 'insert', 'mappable', 'pop', 'remove', 'reverse', 'sort', 'type'] * * * * * * * * * * Traceback (most recent call last): File ./contour_demo.py, line 30, in ? clabel(CS, inline=1, fontsize=10) File /usr/lib/python2.4/site-packages/matplotlib/pylab.py, line 1731, in clabel ret = gca().clabel(*args, **kwargs) File /usr/lib/python2.4/site-packages/matplotlib/axes.py, line 1241, in clabel return self._contourLabeler.clabel(*args, **kwargs) File /usr/lib/python2.4/site-packages/matplotlib/contour.py, line 150, in clabel levels = [con._label for con in contours] AttributeError: _label X Error: BadDevice, invalid or uninitialized input device 166 Major opcode: 144 Minor opcode: 3 Resource id: 0x0 Failed to open device X Error: BadDevice, invalid or uninitialized input device 166 Major opcode: 144 Minor opcode: 3 Resource id: 0x0 Failed to open device [-0.8666166 ,-0.49865195,-0.13068729, 0.23727736, 0.60524202, 0.97320667, 1.34117133,] type: type 'array' ['__copy__', '__deepcopy__', 'astype', 'byteswapped', 'copy', 'iscontiguous', 'itemsize', 'resize', 'savespace', 'spacesaver', 'tolist', 'toscalar', 'tostring', 'typecode'] * * * * * * * * * * a list of 7 LineCollection objects type: class 'matplotlib.cbook.silent_list' ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__dict__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__module__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__str__', '__weakref__', 'append', 'count', 'extend', 'index', 'insert', 'mappable', 'pop', 'remove', 'reverse', 'sort', 'type'] * * * * * * * * * * Traceback (most recent call last): File ./contour_demo.py, line 30, in ? clabel(CS, inline=1, fontsize=10) File /usr/lib/python2.4/site-packages/matplotlib/pylab.py, line 1731, in clabel ret = gca().clabel(*args, **kwargs) File /usr/lib/python2.4/site-packages/matplotlib/axes.py, line 1241, in clabel return self._contourLabeler.clabel(*args, **kwargs) File /usr/lib/python2.4/site-packages/matplotlib/contour.py, line 150, in clabel levels = [con._label for con in contours] AttributeError: _label _ It's Hotmail's 10th Birthday! Come and play Pass the Parcel http://www.msnpasstheparcel.com - 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.phpp=sourceforgeCID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] error in simple plot command
Hello, If I do the following: plot([1],[1],'o') it plots the one dot correctly. if, however, one of those numbers is zero: plot([1],[0],'o') I get a floating point/divide by zero error: /usr/lib/python2.4/site-packages/matplotlib/ticker.py in scale_range(vmin, vmax, n, threshold) 731 dv = abs(vmax - vmin) 732 meanv = 0.5*(vmax+vmin) -- 733 var = dv/max(abs(vmin), abs(vmax)) 734 if var 1e-12: 735 return 1.0, 0.0 ZeroDivisionError: float division Is there a fix for this? In [11]:matplotlib.__version__ Out[11]:'0.87.2' running linux, python 2.4. thanks, Brian Blais -- - [EMAIL PROTECTED] http://web.bryant.edu/~bblais - 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.phpp=sourceforgeCID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] error in simple plot command
Brian Blais wrote: plot([1],[0],'o') I get a floating point/divide by zero error: /usr/lib/python2.4/site-packages/matplotlib/ticker.py in scale_range(vmin, vmax, n, threshold) 731 dv = abs(vmax - vmin) 732 meanv = 0.5*(vmax+vmin) -- 733 var = dv/max(abs(vmin), abs(vmax)) 734 if var 1e-12: 735 return 1.0, 0.0 ZeroDivisionError: float division Is there a fix for this? You have to upgrade. In [39]: plot([1],[0],'o') Out[39]: [matplotlib.lines.Line2D instance at 0xa38ac80c] In [40]: matplotlib.__version__ Out[40]: '0.87.7' In [41]: matplotlib.__revision__ Out[41]: '$Revision: 2835 $' -- cheers, steve Random number generation is the art of producing pure gibberish as quickly as possible. - 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.phpp=sourceforgeCID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] error in simple plot command
You need to update your mpl to the current release or svn. This was fixed quite a few months ago, but I don't remember exactly when. Eric Brian Blais wrote: Hello, If I do the following: plot([1],[1],'o') it plots the one dot correctly. if, however, one of those numbers is zero: plot([1],[0],'o') I get a floating point/divide by zero error: /usr/lib/python2.4/site-packages/matplotlib/ticker.py in scale_range(vmin, vmax, n, threshold) 731 dv = abs(vmax - vmin) 732 meanv = 0.5*(vmax+vmin) -- 733 var = dv/max(abs(vmin), abs(vmax)) 734 if var 1e-12: 735 return 1.0, 0.0 ZeroDivisionError: float division Is there a fix for this? In [11]:matplotlib.__version__ Out[11]:'0.87.2' running linux, python 2.4. thanks, Brian Blais - 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.phpp=sourceforgeCID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Some remarks/questions about perceived slowness of matplotlib
David, I have made some changes in svn that address all but one of the points you made: [] if self.clip: mask = ma.getmaskorNone(val) if mask == None: val = ma.array(clip(val.filled(vmax), vmin, vmax)) else: val = ma.array(clip(val.filled(vmax), vmin, vmax), mask=mask) The real problem here is that I should not have been using getmaskorNone(). In numpy.ma, we need nomask, not None, so we want an ordinary getmask() call. ma.array(, mask=ma.nomask) is very fast, so the problem goes away. Actually, the problem is in ma.array: with a value of mask to None, it should not make a difference between mask = None or no mask arg, right ? But it does, because for numpy it needs to be nomask; it does something with None, but whatever it is, it is very slow. I didn't change ma.array to keep my change as local as possible. To change only this operation as above gives a speed up from 1.8 s to ~ 1.0 s for to_rgba, which means calling show goes from ~ 2.2 s to ~1.4 s. I also changed result = (val-vmin)/float(vmax-vmin) to invcache= 1.0 / (vmax - vmin) result = (val-vmin) * invcache This is the one I did not address. I don't understand how this could be making much difference, and some testing using ipython and %prun with 1-line operations showed little difference with variations on this theme. The fastest would appear to be (and logically should be, I think) result = (val-vmin)*(1.0/(vmax-vmin)), but I don't think it makes much difference--it looks to me like maybe 10-20 msec, not 100, on my Pentium M 1.6 Ghz. Maybe still worthwhile, so I may yet make the change after more careful testing. which gives a moderate speed up (around 100 ms for a 8000x256 points array). Once you make both those changes, the clip call is by far the most expensive operation in normalize functor, but the functor is not really expensive anymore compared to the rest, so this is not where I looked at. For the where calls in Colormap functor, I was wondering if they are necessary in all cases: some of those calls seem redundant, and it may be possible to detect that before calling them. This should be both easier and faster, at least in this case, than having a fast where ? You hit the nail squarely: where() is the wrong function to use, and I have eliminated it from colors.py. The much faster replacement is putmask, which does as well as direct indexing with a Boolean but works with all three numerical packages. I think that using the fast putmask is better than trying to figure out special cases in which there would be nothing to put, although I could be convinced otherwise. I understand that support of multiple array backend, support of mask arrays have cost consequences. But it looks like it may be possible to speed things up for cases where an array has only meaningful values/no mask. The big gains here were essentially bug fixes--picking the appropriate function (getmask versus getmaskorNone and putmask versus where). Here is the colors.py diff: --- trunk/matplotlib/lib/matplotlib/colors.py 2006/12/03 21:54:38 2906 +++ trunk/matplotlib/lib/matplotlib/colors.py 2006/12/14 08:27:04 2923 @@ -30,9 +30,9 @@ import re -from numerix import array, arange, take, put, Float, Int, where, \ +from numerix import array, arange, take, put, Float, Int, putmask, \ zeros, asarray, sort, searchsorted, sometrue, ravel, divide,\ - ones, typecode, typecodes, alltrue + ones, typecode, typecodes, alltrue, clip from numerix.mlab import amin, amax import numerix.ma as ma import numerix as nx @@ -536,8 +536,9 @@ lut[0] = y1[0] lut[-1] = y0[-1] # ensure that the lut is confined to values between 0 and 1 by clipping it -lut = where(lut 1., 1., lut) -lut = where(lut 0., 0., lut) +clip(lut, 0.0, 1.0) +#lut = where(lut 1., 1., lut) +#lut = where(lut 0., 0., lut) return lut @@ -588,16 +589,16 @@ vtype = 'array' xma = ma.asarray(X) xa = xma.filled(0) -mask_bad = ma.getmaskorNone(xma) +mask_bad = ma.getmask(xma) if typecode(xa) in typecodes['Float']: -xa = where(xa == 1.0, 0.999, xa) # Tweak so 1.0 is in range. +putmask(xa, xa==1.0, 0.999) #Treat 1.0 as slightly less than 1. xa = (xa * self.N).astype(Int) -mask_under = xa 0 -mask_over = xa self.N-1 -xa = where(mask_under, self._i_under, xa) -xa = where(mask_over, self._i_over, xa) -if mask_bad is not None: # and sometrue(mask_bad): -xa = where(mask_bad, self._i_bad, xa) +# Set the over-range indices before the under-range; +# otherwise the under-range values get converted to over-range. +putmask(xa, xaself.N-1,
Re: [Matplotlib-users] error bars, plot_date, and connected line
I've been able to figure out how to easily do error bars on a plot_date. Here is how I do it: The variables coming in are dates which is an array of my dates (in days since 0001-01-01), averages, p10 (which is the bottom of my error bars), and p90 (which is the top of my error bars) plot_date(dates, averages, 'bo') # Draw the tops of the error bars ax.vlines(dates,averages,p90) ax.hlines(p90,dates-.25,dates+.25) # Draw the bottom part of the error bars ax.vlines(dates,averages,p10) ax.hlines(p10,dates-.25,dates+.25) It's pretty sweet. I'm having other problems which I will post separately, but this is working well. On Dec 3, 2006, at 12:02 PM, Pierre GM wrote: On Saturday 02 December 2006 17:39, Simson Garfinkel wrote: Hi. I'm interested in creating a date plot showing bandwidth along a link. I want to have a dot in the center of each date with the average bandwidth and use the error bars to show the 25th and 75th percentiles. I've been trying to figure out how to do this and am having problems. My 2c: Don't bother yet about dates: first get the plot as you want it, assuming that your x data are floats (use date2num if needed). Then you can tackle the problem of displaying dates. If you poke around the sources (axes.py). you'll find that 'plot_date' is only 'plot', where a couple of extra parameters are set: if xdate: self.xaxis_date(tz) 'xdate' is a flag indicating whether the data on the x axis are dates (True) or not (False), 'tz' is the timezone flag (default to None), and 'self' is your current axes object (you can get its handle by gca() if you haven't specified it otherwise). Combining these pieces of information should to the trick (or most of it). Let us know how it goes anyway. P. - 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.phpp=sourceforgeCID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] dateformatter doesn't
Greetings. I've been having lots of luck with my date plots. But I've been having a problem getting the dateformatter to work. I'm using the code below. The dates keep getting formatted with the default, Sep 28 2006 instead of what I want, Sep 28 Any thoughts? from datetime import date,timedelta from matplotlib.dates import MonthLocator, WeekdayLocator, DateFormatter,MONDAY,SATURDAY from pylab import * def dateplot(): dates = drange(date(2006,10,1),date(2006,12,1),timedelta(days=1)) vals = 500*(randn(len(dates))+2) figure(num=1, figsize=(6.5,4)) axes([.15,.3,.8,.5]) ax = gca() # get the current graphics region title(rAverage daily bandwidth) ax.xaxis.set_major_formatter(DateFormatter('%b %d')) ax.yaxis.set_major_formatter(FormatStrFormatter('%3.0f KBps')) plot_date(dates, vals, 'bo') # Rotate the labels labels = ax.get_xticklabels() setp(labels,'rotation',90,fontsize=8) grid(True) savefig(x.pdf,format='pdf') if(__name__=='__main__'): dateplot() - 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.phpp=sourceforgeCID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] contour_demo.py
I don't recognize the error output at all, but it looks like you have an old version. The current release is 0.87.7. I don't know of any released version in which contour_demo.py did not run at all, though. The X errors make me wonder whether you are trying to run from inside an IDE. My suggestion would be to delete the installation you have, do a fresh install of the current version, and then try running demos on the command line, making sure the demos are from the newly installed version. If you still have a problem, tell us what version you are running, how it was installed, and on what kind of system. Eric Mohammad Hammoudeh wrote: Hi everybody, I'm trying to run contour_demo.pp example but I'm having this error. Anybody can help? Thanks, X Error: BadDevice, invalid or uninitialized input device 166 Major opcode: 144 Minor opcode: 3 Resource id: 0x0 Failed to open device X Error: BadDevice, invalid or uninitialized input device 166 Major opcode: 144 Minor opcode: 3 Resource id: 0x0 Failed to open device [-0.8666166 ,-0.49865195,-0.13068729, 0.23727736, 0.60524202, 0.97320667, 1.34117133,] type: type 'array' ['__copy__', '__deepcopy__', 'astype', 'byteswapped', 'copy', 'iscontiguous', 'itemsize', 'resize', 'savespace', 'spacesaver', 'tolist', 'toscalar', 'tostring', 'typecode'] * * * * * * * * * * a list of 7 LineCollection objects type: class 'matplotlib.cbook.silent_list' ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__dict__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__module__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__str__', '__weakref__', 'append', 'count', 'extend', 'index', 'insert', 'mappable', 'pop', 'remove', 'reverse', 'sort', 'type'] * * * * * * * * * * Traceback (most recent call last): File ./contour_demo.py, line 30, in ? clabel(CS, inline=1, fontsize=10) File /usr/lib/python2.4/site-packages/matplotlib/pylab.py, line 1731, in clabel ret = gca().clabel(*args, **kwargs) File /usr/lib/python2.4/site-packages/matplotlib/axes.py, line 1241, in clabel return self._contourLabeler.clabel(*args, **kwargs) File /usr/lib/python2.4/site-packages/matplotlib/contour.py, line 150, in clabel levels = [con._label for con in contours] AttributeError: _label X Error: BadDevice, invalid or uninitialized input device 166 Major opcode: 144 Minor opcode: 3 Resource id: 0x0 Failed to open device X Error: BadDevice, invalid or uninitialized input device 166 Major opcode: 144 Minor opcode: 3 Resource id: 0x0 Failed to open device [-0.8666166 ,-0.49865195,-0.13068729, 0.23727736, 0.60524202, 0.97320667, 1.34117133,] type: type 'array' ['__copy__', '__deepcopy__', 'astype', 'byteswapped', 'copy', 'iscontiguous', 'itemsize', 'resize', 'savespace', 'spacesaver', 'tolist', 'toscalar', 'tostring', 'typecode'] * * * * * * * * * * a list of 7 LineCollection objects type: class 'matplotlib.cbook.silent_list' ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__dict__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__module__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__str__', '__weakref__', 'append', 'count', 'extend', 'index', 'insert', 'mappable', 'pop', 'remove', 'reverse', 'sort', 'type'] * * * * * * * * * * Traceback (most recent call last): File ./contour_demo.py, line 30, in ? clabel(CS, inline=1, fontsize=10) File /usr/lib/python2.4/site-packages/matplotlib/pylab.py, line 1731, in clabel ret = gca().clabel(*args, **kwargs) File /usr/lib/python2.4/site-packages/matplotlib/axes.py, line 1241, in clabel return self._contourLabeler.clabel(*args, **kwargs) File /usr/lib/python2.4/site-packages/matplotlib/contour.py, line 150, in clabel levels = [con._label for con in contours] AttributeError: _label _ It's Hotmail's 10th Birthday! Come and play Pass the Parcel http://www.msnpasstheparcel.com - 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.phpp=sourceforgeCID=DEVDEV
[Matplotlib-users] Horizontal grid lines?
HI. I wand to have just horizontal grid lines. Is there any way to do this? Thanks! - 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.phpp=sourceforgeCID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Horizontal grid lines?
Simson Garfinkel wrote: HI. I wand to have just horizontal grid lines. Is there any way to do this? Thanks! gca().yaxis.grid(True) gca().xaxis.grid(False) Here is the grid method docstring: def grid(self, b=None, which='major', **kwargs): Set the axis grid on or off; b is a boolean use which = 'major' | 'minor' to set the grid for major or minor ticks if b is None and len(kwargs)==0, toggle the grid state. If kwargs are supplied, it is assumed you want the grid on and b will be set to True kwargs are used to set the line properties of the grids, eg, xax.grid(color='r', linestyle='-', linewidth=2) Eric - 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.phpp=sourceforgeCID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users