[Matplotlib-users] surface plot...
hello I have problems to plot surfaces like f(x,y)=x*y... for example plot_surface([1,2,3], [4,5,6], [7,8,9]) doesn't work either... I imported the following: from numpy import * import pylab as p import matplotlib.axes3d as p3 does anybody have an advice? -- Feel free - 5 GB Mailbox, 50 FreeSMS/Monat ... Jetzt GMX ProMail testen: http://www.gmx.net/de/go/promail - 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] what is the old default font?
Hello List - A while back, the default font changed in the matplotlibrc file. Does anybody recall what the old default font was? I kinda liked it better than the current font, but I don't recall what it was. Thanks, Mark - 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] segfault with TkAgg and any GUI in 2.5
Numarray does not work with Python 2.5 on 64 bit Linux. If this is a 64 bit Linux machine try using numpy instead. Nadia Dencheva Matt Beal wrote: Having upgraded to 2.5, I get a segfault when running a very simple plot script (test.py) at the show() function. Prior to show() I can save to file and the result looks good. The GUI is crashing on show(). Any suggestions to fix welcome (I'm guessing many of you know the solution to this problem). Annoying debug information below: Thanks! -Matt hostname:~/.matplotlibcat test.py from pylab import * plot([1,2,3]) show() hostname:~/.matplotlibpython test.py --verbose-debug-annoying -dTkAgg matplotlib data path /python2.5/site-packages/matplotlib/mpl-data $HOME=/home/username loaded rc file /home/username/.matplotlib/matplotlibrc matplotlib version 0.90.0 verbose.level debug-annoying interactive is False platform is linux2 loaded modules: ['_bisect', '_sha512', 'pylab', 'datetime', 'matplotlib.tempfile ', 'distutils.sysconfig', 'encodings.encodings', 'str uct', 'tempfile', 'pytz.os', 'zipimport', 'string', 'matplotlib.__future__', 'pytz.tzinfo', ' pytz.datetime', 'distutils.re http://distutils.re', 'bisect' , 'signal', 'random', 'matplotlib.pytz', 'locale', 'encodings', 'dateutil', ' matplotlib.warnings', 'pytz.pytz', 'matplotlib.sys', 're ', 'math', 'fcntl', 'UserDict', 'distutils.os', 'matplotlib', 'codecs', 'md5', '_locale', ' matplotlib.os', 'thread', 'itertools', 'di stutils.sys', 'os', '__future__', '_sre', '__builtin__', 'matplotlib.re http://matplotlib.re', 'operator', ' distutils.string', 'matplotlib.datetime', 'pos ixpath', 'errno', 'binascii', 'sre_constants', '_sha256', 'matplotlib.md5', 'types', 'pytz.sys', '_codecs', 'pytz', 'copy', '_struct' , '_types', 'matplotlib.dateutil', 'hashlib', 'distutils', 'posix', 'encodings.aliases', 'exceptions', 'sre_parse', 'pytz.bisect', 'd istutils.distutils ', 'copy_reg', 'sre_compile', '_hashlib', '_random', 'site', '__main__', 'shutil', 'strop', 'encodings.codecs', 'ge ttext', 'pytz.sets ', 'stat', 'warnings', 'encodings.types', 'encodings.ascii', 'sys', 'os.path', 'pytz.gettext', 'matplotlib.distutil s', 'distutils.errors', 'linecache', ' matplotlib.shutil', 'sets'] numerix numarray 1.5.2 font search path ['/python2.5/site-packages/matplotlib/mpl-data'] trying fontname /python2.5/site-packages/matplotlib/mpl-data/cmtt10.ttf trying fontname /python2.5/site-packages/matplotlib/mpl-data/VeraMoIt.ttf trying fontname /python2.5/site-packages/matplotlib/mpl-data/cmex10.ttf trying fontname /python2.5/site-packages/matplotlib/mpl-data/VeraBI.ttf trying fontname /python2.5/site-packages/matplotlib/mpl-data/VeraBd.ttf trying fontname /python2.5/site-packages/matplotlib/mpl-data/cmmi10.ttf trying fontname /python2.5/site-packages/matplotlib/mpl-data/VeraSeBd.ttf trying fontname /python2.5/site-packages/matplotlib/mpl-data/cmr10.ttf trying fontname /python2.5/site-packages/matplotlib/mpl-data/VeraMono.ttf trying fontname /python2.5/site-packages/matplotlib/mpl-data/cmsy10.ttf trying fontname /python2.5/site-packages/matplotlib/mpl-data/Vera.ttf CONFIGDIR=/home/username/.matplotlib loaded ttfcache file /home/username/.matplotlib/ttffont.cache backend TkAgg version 8.5 FigureCanvasAgg.draw RendererAgg.__init__ RendererAgg.__init__ width=650.0, height=490.0 RendererAgg.__init__ _RendererAgg done RendererAgg.__init__ done RendererAgg._get_agg_font findfont found sans-serif, normal, normal 400, normal, 12.0 findfont returning /python2.5/site-packages/matplotlib/mpl-data/Vera.ttf RendererAgg._get_agg_font RendererAgg.draw_text RendererAgg._get_agg_font RendererAgg.points_to_pixels RendererAgg.points_to_pixels RendererAgg._get_agg_font RendererAgg._get_agg_font RendererAgg.draw_text RendererAgg._get_agg_font RendererAgg.points_to_pixels RendererAgg.points_to_pixels RendererAgg._get_agg_font RendererAgg._get_agg_font RendererAgg.draw_text RendererAgg._get_agg_font RendererAgg.points_to_pixels RendererAgg.points_to_pixels RendererAgg._get_agg_font RendererAgg._get_agg_font RendererAgg.draw_text RendererAgg._get_agg_font RendererAgg._get_agg_font RendererAgg._get_agg_font RendererAgg.draw_text RendererAgg._get_agg_font RendererAgg._get_agg_font RendererAgg._get_agg_font RendererAgg.draw_text RendererAgg._get_agg_font RendererAgg.points_to_pixels RendererAgg.points_to_pixels RendererAgg._get_agg_font RendererAgg._get_agg_font RendererAgg.draw_text RendererAgg._get_agg_font RendererAgg.points_to_pixels RendererAgg.points_to_pixels RendererAgg._get_agg_font RendererAgg._get_agg_font RendererAgg.draw_text RendererAgg._get_agg_font RendererAgg.points_to_pixels RendererAgg.points_to_pixels RendererAgg._get_agg_font RendererAgg._get_agg_font RendererAgg.draw_text RendererAgg._get_agg_font
Re: [Matplotlib-users] surface plot...
On 3/28/07, jens haemmerling [EMAIL PROTECTED] wrote: I have problems to plot surfaces like f(x,y)=x*y... for example plot_surface([1,2,3], [4,5,6], [7,8,9]) doesn't work either... I imported the following: from numpy import * import pylab as p import matplotlib.axes3d as p3 does anybody have an advice? You can do surface plots with axe3d, but mpl isn't really suited for 3d plotting since 3d plotting is nascent and not supported. We include it in hopes that someone else will ike it and improve it but that hasn't happened yet. Personally, unless you are doing interactive stuff like rotating your figure, surface plots don't help much, and mpl 3d is really too slow for interactive 3d. I use imshow or pcolor with colormapping, which will give you just about all the information you can get out of a non-interactive 3d plot. JDH - 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] matlab, idle, interactivity and teaching
Hello to all, I've thread that apperead some time ago on this list about matlab and teaching. I've discovered python recently and translated part of the routine I use in python (www.chemometrics.it). Some of my collegue asked me if I could show them how to use python. For matlab user I guess the first problem is to setup everything, but I just fixed it preparing a directory with all the package I need and a matplotlibrc file for interactive mode + a shortcut for idle -n use. The second problem is that people now wants some bells and whistles of matlab that I have to admit sometime can be very helpful for saving time. The bells and whistles are about the workspace. It's difficult to cut and paste from gnumeric/excel (I generally use txt file but it's no so immediate) and also there is no visual workspace. I cannot succeed also in saving workspace (I know there is a function so iosave.mat but I didn't manage easily hot to use it) For overpass this problems I've tried to use QME-DEV which is in early stage of development (alpha) but promise well. What people like of python/matplot/scipy -its free ;) -they like a lot the plotting style and capabilities (they find the png and svg file very clear and accurate) -they like IDLE as editor (ehy it's has the same color of matlab ;) ! ) So my question is . Do you have a similar experience ? How do you help people in moving the first step ? do you use (and also does it exist) a more friendly environment than IDLE except from QME-DEV. I know that this question may look silly, but in my opinion also how much is user friendly a software is very important for getting new users. Cheers to all Giorgio - 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] creating live plot (update while data is arriving)
On Mar 27, 2007, at 12:35 PM, Antonino Ingargiola wrote: I'm searching to display in realtime some data read serial port. The data is a 2D matrix and is read element wise from the serial, one pixel each one (or more) seconds. You shouldn't have any problems making this happen, although it requires a lot more legwork than creating normal interactive plots. I'm running the script from ipython -pylab using the command run scriptname. After loading the script I interactively launch the function that start the data acquisition and I would like to see the acquired data so far. I've never tried to do something like this using pylab before, so I probably can't be of much help there. However, I can point you toward an example of how to do it from within wxPython using a timer. In the loop that perform the data acquisition I'm currently calling this function to plot data: def plot_data_in_itinere(data, **kwargs): global first_plot d = data.ravel()[find(data.ravel() 0)] m = d.mean() vr = round(5*d.std() / m, 3) #clf() title('Scanning Data') xlabel('Mean Value: '+str(int(round(m)))+' -- Relative Variation: '+str(vr)) b,t = ylim() ylim(t,b) imshow(data.astype(float), interpolation='nearest', vmin=0, origin='lower', **kwargs) if first_plot: colorbar() first_plot = False However the call to the function is blocking. So the acquisition time is longer (not only I have to wait the data but I have to wait the plot too). You should probably do the acquisition asynchronously by running it in a separate thread. That thread would read in the data one point at a time, perform any pre-processing, and post the results to a place that's shared between it and the main plotting thread. The main thread would periodically check and see if the shared data has changed and redraw the plot if needed. I'm not sure how hard this is to do in a reasonable way in pylab, but I've used this approach before in wxPython GUIs. Furthermore, this function plot the new data above the old one, so the plot becomes slower and slower while the acquisition goes on. If I uncommented the cla() line, I get a plot that is blank most of the time and that shows the data only for a fraction of second while the new plot is performed. ` You might want to consider create a mock data source that generates a stream of values from some pre-collected data or Python's random module. That would let you work on debugging the plotting end of things first. It would also make it easier for you to share your code with the list. Is there a way to update (or substitute) the current showed matrix data, deleting the old plots (in the axis). I have to confess that I've have not understand well how the pylab interactive mode works. pylab.imshow() returns a matplotlib.image.AxesImage object. It looks like you can update the data array using its set_data() method. The class documentation is available on the matplotlib website: http://matplotlib.sourceforge.net/matplotlib.image.html#AxesImage Ideally the plot should be performed in background, while the script goes on and wait the next data arrival. You'd almost certainly be happier doing things the other way around. Most GUI toolkits are extremely fussy about what thread the GUI event loop runs in. For example, wxPython requires App.MainLoop() be called from the thread that first imported the wxPython module. That being said, it's possible to run the GUI thread in the background -- the iPython wizards might be able to help you figure it out. I've tried to do this with a simple gtk app that embeds a matplotlib plot. Hoever, I don't know how to send the application in background. I've tried to do something like this: snip the PlotScanApp implement the gui (full files attached). Running the script the image should be updated with random data each 1 sec. but only the first image is showed. I suppose this is not the way to put a gui drawing app in background... Well, using pylab from within a GUI application is a bit dodgy to begin with. I can see a few potential problems. The first is that you're calling plotting commands from within the main thread, although the GUI is running in a background thread. You might try doing the plotting from within the GUI thread by having a timer fire once a second to redraw the plot. The second problem is that you're not calling pylab.draw(), which forces the current figure to redraw itself. Whether or not pylab is running in interactive mode might be a factor here. There's some documentation about interactive mode and the ion()/ioff() commands here: http://matplotlib.sourceforge.net/interactive.html Ken - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay
Re: [Matplotlib-users] creating live plot (update while data is arriving)
On 3/28/07, Ken McIvor [EMAIL PROTECTED] wrote: You'd almost certainly be happier doing things the other way around. Most GUI toolkits are extremely fussy about what thread the GUI event loop runs in. For example, wxPython requires App.MainLoop() be called from the thread that first imported the wxPython module. That being said, it's possible to run the GUI thread in the background -- the iPython wizards might be able to help you figure it out. No, the limitation you describe is there just as much. What we do in ipython is push the *user code* execution into the secondary thread, to make sure we keep the GUI toolkits happy for the very reasons you outline. Cheers, f - 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] Migration from Matlab: translator and EEGlab
Hi, I have to question that will help some colleagues/friends of mine to switch to python from matlab. 1 - is there an automatic translator of code from matlab to python/numpy/matplotlib? I believe it would be very easy to implement due the similar syntax between the two. I could do something similar myself but first I better make sure it doesn't exist yet. 2 - Is there a python/numpy/mpl equivalent of EEGlab? see: http://www.sccn.ucsd.edu/eeglab/ thanks Giorgio - 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] Migration from Matlab: translator and EEGlab
On 3/28/07, Giorgio F. Gilestro [EMAIL PROTECTED] wrote: Hi, I have to question that will help some colleagues/friends of mine to switch to python from matlab. 1 - is there an automatic translator of code from matlab to python/numpy/matplotlib? I believe it would be very easy to implement due the similar syntax between the two. I could do something similar myself but first I better make sure it doesn't exist yet. None that I know of, and it probably wouldn't be easy. For one thing, matlab uses parentheses for function calls and indexing, and it is probably not always obvious which is which for a translator. One could write something that got it mostly right and flagged ambiguities, but I think you should expect that a human would have to clean it up afterwards unless you attempt something ambitious and not easy. Prove me wrong! 2 - Is there a python/numpy/mpl equivalent of EEGlab? see: http://www.sccn.ucsd.edu/eeglab/ There is pbrain, which is not and does not attempt to be an equivalent of EEGLab, but it is an EEG viewer/analysis package in python, which uses matplotlib (and VTK). It is specialized for spectral analysis, but could be extended to do other things. http://neuroimaging.scipy.org/pbrain/ I first wrote an EEG analysis package in matlab, and after becoming frustrated with the lack of good support for complex data structures, networking, and programming paradigms, I jettisoned it for python and wrote pbrain. I wrote matplotlib in support of the pbrain application, so some of the work has already been done :-) JDH - 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] tick locations in new matshow()
Suresh Pillai wrote: The new matshow() seems to like ticks every 4 units (or multiples of 4 for larger scales) rather than the normal, more desirable every 5 units. Compare: import pylab matrix = pylab.rand(30,30) pylab.matshow(matrix) pylab.show() with import pylab matrix = pylab.rand(30,30) pylab.imshow(matrix) pylab.show() Looking at the code right now, but since matshow() calls imshow(), it is not obvious to me. I presume it has something to do with the line ax = fig.add_axes([0.15, 0.09, 0.775, 0.775]) No, this determines where in the figure window the axes will be located. in matshow(). Still learning the internals of mpl ... It is a question of the tick locator that is used. imshow is using the default MaxNLocator, which generally does a nice job but will sometimes put ticks on non-integer locations. Therefore, for matshow, I added a kwarg to guarantee use of integer locations. I should be able to tweak it so that its results differ from the default MaxNLocator only when the latter would produce non-integers. That was the intention. Also, as mentioned in a previous thread, the new matshow() is missing tick marks on the lower x-axis. I thought I fixed that in svn, but it looks like I was foiled by a bug somewhere in axis.py. I'll have to track it down. To be continued... Eric Cheers, Suresh - 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] specgram: Warning: divide by zero encountered in log10
Hi guys, I'm trying to make a specgram() for some wave samples that I have read into 'data' using pyaudiolab's read_frames() (put into wavread()) When I do from wavread import * from pylab import * from statistics import * data, datasize, samplerate, channels = wavread(myfile.wav) specgram(data) I get: Warning: divide by zero encountered in log10 (array([[ 2.26730611e-02, 1.51890672e-02, 7.78123371e-03, ..., 0.e+00, 0.e+00, 0.e+00], [ 9.11969843e-03, 2.81931459e-03, 3.13995580e-03, ..., 0.e+00, 0.e+00, 0.e+00], [ 7.25346631e-04, 4.83291216e-05, 2.59076878e-04, ..., 0.e+00, 0.e+00, 0.e+00], ..., [ 5.19279887e-08, 1.53242938e-07, 1.46461798e-07, ..., 0.e+00, 0.e+00, 0.e+00], [ 1.00769359e-07, 2.00314891e-07, 3.04618029e-07, ..., 0.e+00, 0.e+00, 0.e+00], [ 2.86252093e-08, 5.42052713e-07, 1.50494595e-07, ..., 0.e+00, 0.e+00, 0.e+00]]), array([ 0. , 0.0078125, 0.015625 , 0.0234375, 0.03125 , 0.0390625, 0.046875 , 0.0546875, 0.0625 , 0.0703125, 0.078125 , 0.0859375, 0.09375 , 0.1015625, 0.109375 , 0.1171875, 0.125, 0.1328125, 0.140625 , 0.1484375, 0.15625 , 0.1640625, 0.171875 , 0.1796875, 0.1875 , 0.1953125, 0.203125 , 0.2109375, 0.21875 , 0.2265625, 0.234375 , 0.2421875, 0.25 , 0.2578125, 0.265625 , 0.2734375, 0.28125 , 0.2890625, 0.296875 , 0.3046875, 0.3125 , 0.3203125, 0.328125 , 0.3359375, 0.34375 , 0.3515625, 0.359375 , 0.3671875, 0.375, 0.3828125, 0.390625 , 0.3984375, 0.40625 , 0.4140625, 0.421875 , 0.4296875, 0.4375 , 0.4453125, 0.453125 , 0.4609375, 0.46875 , 0.4765625, 0.484375 , 0.4921875, 0.5 , 0.5078125, 0.515625 , 0.5234375, 0.53125 , 0.5390625, 0.546875 , 0.5546875, 0.5625 , 0.5703125, 0.578125 , 0.5859375, 0.59375 , 0.6015625, 0.609375 , 0.6171875, 0.625, 0.6328125, 0.640625 , 0.6484375, 0.65625 , 0.6640625, 0.671875 , 0.6796875, 0.6875 , 0.6953125, 0.703125 , 0.7109375, 0.71875 , 0.7265625, 0.734375 , 0.7421875, 0.75 , 0.7578125, 0.765625 , 0.7734375, 0.78125 , 0.7890625, 0.796875 , 0.8046875, 0.8125 , 0.8203125, 0.828125 , 0.8359375, 0.84375 , 0.8515625, 0.859375 , 0.8671875, 0.875, 0.8828125, 0.890625 , 0.8984375, 0.90625 , 0.9140625, 0.921875 , 0.9296875, 0.9375 , 0.9453125, 0.953125 , 0.9609375, 0.96875 , 0.9765625, 0.984375 , 0.9921875, 1. ]), array ([ 6.4000e+01, 1.2800e+02, 1.9200e+02, ..., 9.7344e+04, 9.7408e+04, 9.7472e+04]), matplotlib.image.AxesImage instance at 0x3324fa8) For another sample, I get a nice spectrogram. What can it be about my sample that would give me such an error? What is the error caused by? A Google on the error message provided me with nothing. Sincerely yours Niklas Saers- 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] surface plot...
jens haemmerling wrote: -- Message: 1 Date: Wed, 28 Mar 2007 12:39:05 +0200 From: jens haemmerling [EMAIL PROTECTED] Subject: [Matplotlib-users] surface plot... To: matplotlib-users@lists.sourceforge.net Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=us-ascii hello I have problems to plot surfaces like f(x,y)=x*y... for example plot_surface([1,2,3], [4,5,6], [7,8,9]) doesn't work either... I imported the following: from numpy import * import pylab as p import matplotlib.axes3d as p3 does anybody have an advice? See simple3d.py in the examples: http://matplotlib.sourceforge.net/matplotlib_examples_0.90.0.zip -- Matt - 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] [wxmpl] How to get coordinates from selected rectangle
Hi! I have a wxmpl.PlotPanel object with a cross-hair style cursor (without the full screen crosshairs). When I select a rectangle w/ this cursor it zooms in to that rectangle - great! Now, how do I get the rectangle coordinates (preferably in data coords.) from the rectangle selection event? Thanks! DG - 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] [Fwd: Re: colorbar, setting limits]
I forgot reply to all. ---BeginMessage--- Evan, The solution you are proposing below sounds wrong to me--I am concerned that your color bar is not corresponding to the actual levels you are plotting on both plots. I think that what you actually need is closer to the attached script. Eric Evan Mason wrote: Hi Eric, just further to what I said, you can see those white areas in the stripped down version by using a = arange(12, 23, .5) b = arange(17, 27, .5) and then running as before... -Evan On 3/27/07, *Evan Mason* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Thanks, Eric, Yes, that works for the stripped down version, but not for what I am trying to do. The examples I have given have the range of one of the plots nicely fitting inside that of the other (ie, plot 1 range 15 to 26, plot 2 range 17 to 23), but sometimes with what I am doing I have, for example, plot 1 range 15 to 23 and plot 2 range 17 to 25. In this case, passing the levels from plot 1 to plot 2 means that levels 24 and 25 of plot 2 are stripped away; this, at least, is what I think is happening because I have white areas of my plot that weren't there before. It seems to me that it would be quite useful to have the option to override the colorbar range, setting it to be the same as defined by clim, or some other values. As a solution for now, I think I will just use one colorbar for the two plots. Thanks for your help with this, and the tip about being explicit in my programs! -Evan import pylab as P from matplotlib.transforms import Value, Interval from matplotlib.ticker import MaxNLocator N = 12 # target number of contour levels a = P.arange(12, 23, .5) b = P.arange(17, 27, .5) x, y = P.meshgrid(a, b) # get max and min for clim cmin = min(x.min(), y.min()) # cmin = 12 cmax = max(x.max(), y.max()) # cmax = 26.5 # The following needs some convenience methods to make it easier; # but for now, this is how you can automatically generate reasonable # contour levels based on an overall range. # The alternative is to manually specify the levels, e.g., # levels = range(int(cmin), int(cmax+1.0), 2) intv = Interval(Value(cmin), Value(cmax)) locator = MaxNLocator(N+1) locator.set_view_interval(intv) locator.set_data_interval(intv) levels = locator() P.figure(1) CS1 = P.contourf(x, levels=levels) #clim(cmin, cmax) P.colorbar(CS1) P.figure(2) CS2 = P.contourf(y, levels=levels) #clim(cmin, cmax) P.colorbar(CS2) P.show() ---End Message--- - 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] creating live plot (update while data is arriving)
On Mar 28, 2007, at 6:03 PM, Antonino Ingargiola wrote: On 3/28/07, Ken McIvor [EMAIL PROTECTED] wrote: You should probably do the acquisition asynchronously by running it in a separate thread. snip That's exactly what I'd like to do. The problem is that if I run gtk.main() (the gtk main GUI loop) in a separate thread the program stops until I do something on the GUI (for example passing the mouse on it). Does it do this if you run gtk.main() in the main thread (e.g. the interpreter prompt) while doing something else in a background thread? My understanding so far is the following. When the function that execute gtk.main() is executed, python doesn't switch thread until either 100 bytecode instructions are executed or since an I/O (potentially) blocking operation in executed. I think you're more or less correct but are unaware of one important factor. Here's my understanding of how multithreading works in Python... Thread switching is controlled by something called the Global Interpreter Lock, which is implemented in an abstract way on top of an OS lock/mutex object. Only one Python thread runs at a time because the Python interpreter requires a thread to hold the GIL before it can execute bytecode instructions. The running thread holds the GIL while is executes 100 instructions. During this time other Python threads block waiting to acquire the GIL. After it has executed its 100 instructions, the running thread releases the GIL and then attempts to reacquire it. The OS ensures that things are fair by preventing one thread from reacquiring the GIL over and over again when other threads are also waiting for it. Python doesn't actually detect you do something that will block the thread, like an I/O operation. Instead, the C code implementing an I/ O operation like file.write() releases the GIL before performing the operation. This allows a different thread to acquire it and run some more bytecode instructions while the first thread performs its I/O operation. When I'm doing nothing on the GUI application, neither 100 byte code instructions are executed in the thread neither an I/O call is performed, so the whole program (including the *other* threads) stalls. I'm not sure on the details, but the C code that implements gtk.main () almost certainly releases the GIL before running the GUI event loop. Otherwise things like iPython wouldn't be able to run the GUI in a separate thread. So, that's probably not the problem. It's possible that there's another lock that's used to protect access to the gtk module. If that's the case you could be causing deadlock by calling making gtk calls from multiple threads. In my experience it's best to stick to the one-thread rule: the thread that runs the GUI's event loop is the only thread that's allowed to do anything related to the GUI. Basically, I don't know which is the right way to put a Gtk GUI in background, while another thread get the data asynchronously. You probably want to put the GUI in the main thread. The main thread is the only thread in a Python program that receives the KeyboardInterrupt exception when the process receives a SIGINT (i.e. when the user hits ^C in the shell). Also, most Python GUI toolkits require their event loops run from the thread that originally imported the module. BTW, the timer idea is good and eliminates the need to call asynchronously the GUI thread to update the plot, which seems (the latter case) not very simple to do. Yep. It's impossible to inject arbitrary code into a Python thread; the thread has to figure out what it's supposed to do by periodically polling something or retrieving some kind of message by blocking on a queue. Blocking on a queue isn't an option for the GUI thread. You might be able to trigger Gtk signals from a separate thread but in my experience tricks like that can be, well, tricky. Thanks to your suggestion to use the image.set_data method I've created a simplified script (pasted at the end) that demonstrate how to do live-update while acquiring (jep!). Glad I could help! :-) The last think I'm not yet able to do is to update the colorbar to autoscale with the new incoming data. The the script that follows tries to update the colorbar too but it does not work (on matplotlib 0.87 at least). I have no idea if this will help, but you might need to call AxesImage.changed() after calling AxesImage.set_data(). Ken - 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
Re: [Matplotlib-users] specgram: Warning: divide by zero encountered in log10
On 3/28/07, Niklas Saers [EMAIL PROTECTED] wrote: Hi guys, I'm trying to make a specgram() for some wave samples that I have read into 'data' using pyaudiolab's read_frames() (put into wavread()) When I do from wavread import * from pylab import * from statistics import * data, datasize, samplerate, channels = wavread(myfile.wav) specgram(data) I get: Warning: divide by zero encountered in log10 (array([[ 2.26730611e-02, 1.51890672e-02, 7.78123371e-03, ..., 0.e+00, 0.e+00, 0.e+00], [ 9.11969843e-03, 2.81931459e-03, 3.13995580e-03, ..., So there is no traceback, just a warning? Perhaps you could pickle or otherwise store data and write a simple test script which doesn't depend on any external packages (eg waveread) and post a link to the files and we'll take a look. My guess is that there is some frequency that has no power and the call to Z = 10*log10(Pxx) is failing because Pxx is zero for that frequency. We've seen this before, and if anyone has a suggestion on how this case *should* be handled, I'd be happy to hear some suggestions. JDH JDH - 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