[Matplotlib-users] problem with set_data update/refresh in matplotlib using wxpython backend
Hi I am developing a plotting tool using matplotlib and wxpython as backend. I have separate thread for iperf and it creates a text file every time I want to create this thread and this thread finish it's task once it reach the duration(defined by the user). Plot and some text boxes are updated reading this text file every second once I press plot button. My problem is matplotlib keeps the old data and impose new data on the same plot. I am using cla function to clear the axes but how can I clear set_data for every new plot. What I want is to initialize set_data. Anyone here to tell me how can I do that? Hope my post makes sense. If not I will post with some snippets of my tool. Cheers! Rezwan -- View this message in context: http://www.nabble.com/problem-with-set_data-update-refresh-in-matplotlib-using-wxpython-backend-tp21870522p21870522.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] only left and bottom border in figure frame
Dear all, I would like to have a plot where the frame only have left and bottom border. I can not find in the documentation any function to draw the Rectangle contained in figure() only with this 2 lines. It is possilbe? Regards, Zunbeltz -- Dr. Zunbeltz Izaola Helmholtz-Zentrum Berlin für Materialien und Energie GmbH Methods and Instruments (SF1) Glienicker Str. 100 D-14109 Berlin Tel (030) 8062-3179 Fax (030) 8062-2523 Room A 349 -- Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] code searching
You're right, it's the chaco's zooming plot, I confused. Is there a way to have this render with matplotlib? Le jeudi 05 février 2009 à 10:41 -0600, Ryan May a écrit : Lionel Roubeyrie wrote: Hi all, On the matplotlib website I can't find an old example code showing a figure with two vertical plots, where the second represents a zoom of some selected datas in a rectangle of the first axis, and between the two axis there was a trapezoid. If someone has this code, I'll be happy to get it :) Thanks I don't remember a demo like that in matplotlib, but I do remember such a demo for Chaco2. Ryan -- Lionel Roubeyrie chargé d'études LIMAIR - La Surveillance de l'Air en Limousin http://www.limair.asso.fr -- Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] imsave() function
Hi all, I've attached a candidate imsave() to complement imread() in the image.py module. Would my use of pyplot instead of the oo interface preclude its inclusion in image.py? Also, I noticed some problems when I ran the tests with the Wx backends with mpl 0.98.5.2 in Win32. Both of the Wx backends produce incorrect, but different, results. Gary R. import numpy as np import matplotlib as mpl # Backend tests - uncomment in turn # mpl.use('Agg') # mpl.use('TkAgg') # mpl.use('WxAgg') # problem in Win32 with mpl 0.98.5.2 # mpl.use('Wx')# several problems in Win32 with mpl 0.98.5.2 # mpl.use('GTK') # mpl.use('GTKAgg') import matplotlib.pyplot as plt from matplotlib import rcParams import matplotlib.image as mpi from matplotlib import cm def imsave(fname, arr, clims=None, cmap=None, format=None, origin=None): Saves a 2D array as a bitmapped image with one pixel per element. The output formats available depend on the backend being used. Arguments: *fname*: A string containing a path to a filename, or a Python file-like object. If *format* is *None* and *fname* is a string, the output format is deduced from the extension of the filename. *arr*: A 2D array. Keyword arguments: *clims*: clims sets the color scaling for the image. It is a tuple (vmin, vmax) that is passed through to the pyplot clim function. If either *vmin* or *vmax* is None, the image min/max respectively will be used for color scaling. *cmap*: cmap is a colors.Colormap instance. *format*: One of the file extensions supported by the active backend. Most backends support png, pdf, ps, eps and svg. *origin* [ 'upper' | 'lower' ] Indicates where the [0,0] index of the array is in the upper left or lower left corner of the axes. Defaults to the rc image.origin value. ydim, xdim = arr.shape if cmap is None: cmap = eval('cm.' + rcParams['image.cmap']) if origin is None: origin = rcParams['image.origin'] f = plt.figure(figsize=(xdim,ydim), dpi=1) plt.axes([0,0,xdim,ydim]) plt.axis('off') plt.figimage(arr, cmap=cmap, origin=origin) if clims is not None: plt.clim(*clims) plt.savefig(fname, dpi=1, format=format) # tests imsave('test1.png', np.tri(100), origin='lower') imsave('test2.png', np.tri(100), origin='upper') imsave('test3png', np.random.random((100,100)), cmap=cm.Oranges, format='png') imsave('test4.png', np.hstack((np.tri(100)+np.tri(100)[:,::-1],np.vstack((np.eye(50),np.ones((50,50))*0.75,cmap=cm.gray) imsave('test5.png', np.vstack((np.tri(100),np.hstack((np.eye(50),np.ones((50,50))*0.25,cmap=cm.gray) imsave('test6.png', np.vstack((np.ones((100,100)),np.zeros((50,100) imsave('test7.png', np.eye(2)) imsave('test8.png', np.array([[1]])) -- Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] code searching
Lionel Roubeyrie wrote: You're right, it's the chaco's zooming plot, I confused. Is there a way to have this render with matplotlib? The event_handling/zoom_window.py example is kind of similar and might give some clues of where to go. But no, I don't know of a straight-forward version of chaco's example using matplotlib. Patches are accepted. :) Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma -- Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] only left and bottom border in figure frame
On Feb 6, 2009, at 8:45 AM, Zunbeltz Izaola wrote: Dear all, I would like to have a plot where the frame only have left and bottom border. I can not find in the documentation any function to draw the Rectangle contained in figure() only with this 2 lines. It is possilbe? Hi Zunbeltz, Attached is an example of a custom Axes class that does what you want. There are examples at the bottom of the file that show its use. I worked on generalizing this idea for inclusion in MPL, but the code got really nasty, really quickly. On a side note, if any of the MPL devs think this would make a useful API example (since this topic has come up a few times on the list), feel free to do whatever you want with it. Cheers, -Tony #!/usr/bin/env python Frame classes for customizing frame borders that surround the plot axes. import numpy as np import matplotlib.axes as maxes import matplotlib.pyplot as plt import matplotlib.artist as martist import matplotlib.collections as col import matplotlib.projections as projections class Frame(martist.Artist): Draw frame along the edges of the axes patch. Frame position can be controlled upon initialization or by setting `positions` property with a list of positions ['left', 'right', 'top', 'bottom' | 'all'] _position_list = ('left', 'right', 'top', 'bottom') def __init__(self, axes, positions=('left', 'bottom'), **kwargs): `positions` is a list of strings of frame positions to plot. ['left', 'right', 'top', 'bottom' | 'all'] super(Frame, self).__init__() # TODO: allow more keyword configuration self.axes = axes rc = plt.rcParams self.color = kwargs.pop('color', rc['axes.edgecolor']) self.linewidth = kwargs.pop('linewidth', rc['axes.linewidth']) self.linestyle = kwargs.pop('linestyle', 'solid') self.positions = positions def get_data(self): Convenience method returns tuple of (x, y) data in `self.axes` x, y = [], [] ax = self.axes for artist in (ax.lines, ax.patches): if not artist == []: x.append(np.concatenate([a.get_xdata() for a in artist])) y.append(np.concatenate([a.get_ydata() for a in artist])) # TODO: get scatter data from ax.collections return (np.concatenate(x), np.concatenate(y)) def _set_frame_position(self, positions): Set positions where frame will be drawn. `positions` is a list of strings of frame positions to plot. ['left', 'right', 'top', 'bottom' | 'all'] self._frame_on = self._frame_dict_from(positions) def _get_frame_position(self): return [p for p in self._position_list if self._frame_on[p]] # xposition tuples turn on frame for (bottom, top) _xposition_pairs = {(True, False): 'bottom', (False, True): 'top', (True, True): 'both', (False, False): 'none'} def _get_xposition(self, frame_on=None): Returns position that matches `XAxis.set_ticks_position` inputs. `frame_on` is a dict that matches frame positions with bools. if frame_on is None: frame_on = self._frame_on return self._xposition_pairs[(frame_on['bottom'], frame_on['top'])] # yposition tuples turn on frame for (left, right) _yposition_pairs = {(True, False): 'left', (False, True): 'right', (True, True): 'both', (False, False): 'none'} def _get_yposition(self, frame_on=None): Returns position that matches `YAxis.set_ticks_position` inputs. `frame_on` is a dict that matches frame positions with bools. if frame_on is None: frame_on = self._frame_on return self._yposition_pairs[(frame_on['left'], frame_on['right'])] def _frame_dict_from(self, positions): Parse `positions` and return xposition, yposition tuple `positions` is a list of strings of frame positions to plot. ['left', 'right', 'top', 'bottom' | 'all'] frame_dict = dict.fromkeys(self._position_list, False) if 'all' in positions: frame_dict = dict.fromkeys(self._position_list, True) else: for position in positions: frame_dict[position] = True return frame_dict def _set_ticks(self): Overide this method to customize tick positioning. # Draw ticks on axes only where a frame is drawn self.axes.xaxis.set_ticks_position(self._get_xposition()) self.axes.yaxis.set_ticks_position(self._get_yposition()) _frame_lines = dict(bottom=[(0., 0.), (1., 0.)], top=[(0., 1.), (1., 1.)], left=[(0., 0.), (0., 1.)], right=[(1., 0.), (1., 1.)]) def _make_frame(self): Get axis frame specified by `self._frame_on`. lines = [self._frame_lines[p] for p in
Re: [Matplotlib-users] code searching
On Fri, Feb 6, 2009 at 10:56 AM, Ryan May rma...@gmail.com wrote: Lionel Roubeyrie wrote: You're right, it's the chaco's zooming plot, I confused. Is there a way to have this render with matplotlib? The event_handling/zoom_window.py example is kind of similar and might give some clues of where to go. But no, I don't know of a straight-forward version of chaco's example using matplotlib. Patches are accepted. :) The following example is pretty close to what you want I think -- select a span in the upper axes to see the zoom in the lower: http://matplotlib.sourceforge.net/examples/widgets/span_selector.html JDH -- Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] code searching
On Fri, Feb 6, 2009 at 1:10 PM, John Hunter jdh2...@gmail.com wrote: On Fri, Feb 6, 2009 at 10:56 AM, Ryan May rma...@gmail.com wrote: Lionel Roubeyrie wrote: You're right, it's the chaco's zooming plot, I confused. Is there a way to have this render with matplotlib? The event_handling/zoom_window.py example is kind of similar and might give some clues of where to go. But no, I don't know of a straight-forward version of chaco's example using matplotlib. Patches are accepted. :) The following example is pretty close to what you want I think -- select a span in the upper axes to see the zoom in the lower: http://matplotlib.sourceforge.net/examples/widgets/span_selector.html You know, in the back of my mind I just knew I was wrong, but had forgotten about this one. Thanks for jogging my memory. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma -- Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] A contourf bug?
Hi Everyone, Looks like I may have run into a bug for the contourf function. I was able to reproduce the problem on two OS X systems. One was based on 10.5 and the other was on 10.4. The problem appears when you use contourf with alpha 1. With the transparency there appears to be streaks of lines pointing downward from the contour lines. Is this a bug that has been spotted before? Additional information is provided below with a python script to reproduce the problem. Note, this bug was reproduced with a range of different parameters and input values. The script is the easiest way to reproduce the problem. Cheers, Eli Mac OSX Darwin Kernel Version 9.5.0 (Leopard 10.5.5) Matplotlib version: 0.98.3 Matplotlib was installed via EPD, version Py2.5 4.1.30101 i386 Code to show bug: Most of the python code was borrowed from the Matplotlib examples http://matplotlib.sourceforge.net/examples/pylab_examples/contour_demo.html?highlight=contours ## Begin Python Code ### import matplotlib import numpy as np import matplotlib.cm as cm import matplotlib.mlab as mlab import matplotlib.pyplot as plt delta = 0.025 x = np.arange(-3.0, 3.0, delta) y = np.arange(-2.0, 2.0, delta) X, Y = np.meshgrid(x, y) Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) Z = 10.0 * (Z2 - Z1) plt.figure() CS = plt.contourf(X, Y, Z,alpha = 0.7) ## End Python Code ### -- Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] A contourf bug?
Eli Bressert wrote: Hi Everyone, Looks like I may have run into a bug for the contourf function. I was able to reproduce the problem on two OS X systems. One was based on 10.5 and the other was on 10.4. The problem appears when you use contourf with alpha 1. With the transparency there appears to be streaks of lines pointing downward from the contour lines. Is this a bug that has been spotted before? Additional information is provided below with a python script to reproduce the problem. Note, this bug was reproduced with a range of different parameters and input values. The script is the easiest way to reproduce the problem. It is partly inherent in the underlying contouring algorithm, and I think partly reflecting a common characteristic of renderers. On my ubuntu box, the problem shows up in agg, pdf or ps shown with evince, but *not* in svg rendered by eog. The part inherent in the contouring algorithm is that all patches are simply connected--the algorithm does not make annular patches, for example--so there is a vertical cut. With alpha 1, that cut, and for that matter the boundary between one patch and the next, seem to be effectively rendered twice. The contour code is already specifying that the patch should be rendered without a boundary, so I don't know what else can be done. Eric Cheers, Eli Mac OSX Darwin Kernel Version 9.5.0 (Leopard 10.5.5) Matplotlib version: 0.98.3 Matplotlib was installed via EPD, version Py2.5 4.1.30101 i386 Code to show bug: Most of the python code was borrowed from the Matplotlib examples http://matplotlib.sourceforge.net/examples/pylab_examples/contour_demo.html?highlight=contours ## Begin Python Code ### import matplotlib import numpy as np import matplotlib.cm as cm import matplotlib.mlab as mlab import matplotlib.pyplot as plt delta = 0.025 x = np.arange(-3.0, 3.0, delta) y = np.arange(-2.0, 2.0, delta) X, Y = np.meshgrid(x, y) Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) Z = 10.0 * (Z2 - Z1) plt.figure() CS = plt.contourf(X, Y, Z,alpha = 0.7) ## End Python Code ### -- Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users