[Matplotlib-users] Embed in GTK + dynamic plot
Hi all! I'd like to embed a mpl graph into a GTK application (and for that embedding_in_gtk*.py examples are fine) but I would also like to dynamically update the graph with time. Consider like if I want to plot some dynamic system information, like cpu usage, memory occupation, or so. Than I want to gather those info at 1 sec interval, and dynamically update the graph adding the new values. How can I do it? I'm stuck with the update data as they come part (please note I need for GTK embedded mpl code). Thanks in advance, Sandro PS: if there's someone that knows how to gather cpu percentage usage on a linux sys, please tell me :) It seems not that easy to find it out from google ;) -- Sandro Tosi (aka morph, morpheus, matrixhasu) My website: http://matrixhasu.altervista.org/ Me at Debian: http://wiki.debian.org/SandroTosi -- Register Now Save for Velocity, the Web Performance Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Enforcing common view limits
I've realized that using the ParasiteAxes from the mpl_toolkits should do exactly what I'm asking. However, I am having a problem with callbacks when the x and y limits change (try resizing the window). The following script shows that the callback for the second set of axes is not carried out. Is this a bug, or a limitation? Or something I'm doing wrong? Thanks! Thomas --- import matplotlib.pyplot as mpl import numpy as np import mpl_toolkits.axes_grid.parasite_axes as mpl_toolkit def check_callback(ax): print callback for ,ax.name array = np.random.random((100,100)) fig = mpl.figure() ax = mpl_toolkit.SubplotHost(fig,1,1,1,adjustable='datalim') ax.name = first axis ax.callbacks.connect('xlim_changed',check_callback) ax.callbacks.connect('xlim_changed',check_callback) ax2 = ax.twin() ax2.name = second axis ax2.callbacks.connect('ylim_changed',check_callback) ax2.callbacks.connect('ylim_changed',check_callback) fig.add_axes(ax) ax.imshow(array,interpolation='nearest') fig.canvas.draw() --- -- View this message in context: http://www.nabble.com/Enforcing-common-view-limits-tp23334325p23348018.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Register Now Save for Velocity, the Web Performance Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Enforcing common view limits
There was a typo in the script, the callbacks should be ax.name = first axis ax.callbacks.connect('xlim_changed',check_callback) ax.callbacks.connect('ylim_changed',check_callback) ax2 = ax.twin() ax2.name = second axis ax2.callbacks.connect('xlim_changed',check_callback) ax2.callbacks.connect('ylim_changed',check_callback) but the problem remains: check_callback is never called for ax2. Tom -- View this message in context: http://www.nabble.com/Enforcing-common-view-limits-tp23334325p23348806.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Register Now Save for Velocity, the Web Performance Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Fast imshow plotting
I am creating a script that generates images and displays them to the screen in real time. I created the following simple script: __ #!/usr/bin/env python from pylab import * from scipy import * for k in range(1,1): img = standard_normal((40,40)) imshow(img,interpolation=None,animated=True,label=blah) clf() show() __ Now, this script plots the image too slowly. I am forced to use the clf() function so that it doesn't slow down at each iteration of the for loop. Is there a way that I can plot this simple image faster? What's the best way to get imshow() to plot quickly? Thanks for your help. -Joey -- Register Now Save for Velocity, the Web Performance Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Fast imshow plotting
Not sure if this will help, but maybe you can do something like this? --- #!/usr/bin/env python from pylab import * from scipy import * img = standard_normal((40,40)) image = imshow(img,interpolation='nearest',animated=True,label=blah) for k in range(1,1): img = standard_normal((40,40)) image.set_data(img) show() --- Note, interpolation='nearest' can be faster than interpolation=None if your default interpolation is set to bicubic (which it probably is) Does this speed things up? Thomas On May 1, 2009, at 3:31 PM, Joey Wilson wrote: I am creating a script that generates images and displays them to the screen in real time. I created the following simple script: __ #!/usr/bin/env python from pylab import * from scipy import * for k in range(1,1): img = standard_normal((40,40)) imshow(img,interpolation=None,animated=True,label=blah) clf() show() __ Now, this script plots the image too slowly. I am forced to use the clf() function so that it doesn't slow down at each iteration of the for loop. Is there a way that I can plot this simple image faster? What's the best way to get imshow() to plot quickly? Thanks for your help. -Joey -- Register Now Save for Velocity, the Web Performance Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Register Now Save for Velocity, the Web Performance Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Fast imshow plotting
Thomas Robitaille wrote: Not sure if this will help, but maybe you can do something like this? --- #!/usr/bin/env python from pylab import * from scipy import * To run this as a standalone script, without ipython -pylab, you need to include: ion() img = standard_normal((40,40)) image = imshow(img,interpolation='nearest',animated=True,label=blah) for k in range(1,1): img = standard_normal((40,40)) image.set_data(img) show() show() should never be called more than once for a given figure; what you want here is draw(). Eric --- Note, interpolation='nearest' can be faster than interpolation=None if your default interpolation is set to bicubic (which it probably is) Does this speed things up? Thomas On May 1, 2009, at 3:31 PM, Joey Wilson wrote: I am creating a script that generates images and displays them to the screen in real time. I created the following simple script: __ #!/usr/bin/env python from pylab import * from scipy import * for k in range(1,1): img = standard_normal((40,40)) imshow(img,interpolation=None,animated=True,label=blah) clf() show() __ Now, this script plots the image too slowly. I am forced to use the clf() function so that it doesn't slow down at each iteration of the for loop. Is there a way that I can plot this simple image faster? What's the best way to get imshow() to plot quickly? Thanks for your help. -Joey -- Register Now Save for Velocity, the Web Performance Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Register Now Save for Velocity, the Web Performance Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Register Now Save for Velocity, the Web Performance Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] different vertical axes scales
I have two time series, {u_j} and {v_j}, with vastly different scales, but all sampled at the same times, {t_j}. Is there an easy way to plot the two on the same figure, with different vertical axes on the left and the right? -gideon -- Register Now Save for Velocity, the Web Performance Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] different vertical axes scales
On Sat, May 2, 2009 at 5:00 PM, Gideon Simpson simp...@math.toronto.eduwrote: I have two time series, {u_j} and {v_j}, with vastly different scales, but all sampled at the same times, {t_j}. Is there an easy way to plot the two on the same figure, with different vertical axes on the left and the right? Take a look at twinx -- function doc and example links included below: http://matplotlib.sourceforge.net/examples/api/two_scales.html http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.twinx JDH -- Register Now Save for Velocity, the Web Performance Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Embed in GTK + dynamic plot
On Sat, May 2, 2009 at 9:42 AM, Sandro Tosi mo...@debian.org wrote: Hi all! I'd like to embed a mpl graph into a GTK application (and for that embedding_in_gtk*.py examples are fine) but I would also like to dynamically update the graph with time. Consider like if I want to plot some dynamic system information, like cpu usage, memory occupation, or so. Than I want to gather those info at 1 sec interval, and dynamically update the graph adding the new values. How can I do it? I'm stuck with the update data as they come part (please note I need for GTK embedded mpl code). The idioms in the examples/animations dir should be directly portable to an embedded gtk app, eg simple_anim_gtk.py, dynamic_image_gtkagg.py, etc. You will need to either use an idle handle, a timeout handler, or a special event in the gtk event handling framework to trigger an update to the data and draw. You can extend the gobject signals to handle custom events (eg data arrives) if you want to go this route, but since you are trying to illustrate mpl more than gtk (I assume) you may want to go the easy route and use the timeout or idle handler and just check and see if new data has arrived and then update as necessary. PS: if there's someone that knows how to gather cpu percentage usage on a linux sys, please tell me :) It seems not that easy to find it out from google ;) http://tinyurl.com/d7lkga Sorry :-) Couldn't resist (less obnoxious answer http://www.cyberciti.biz/tips/how-do-i-find-out-linux-cpu-utilization.html) JDH -- Register Now Save for Velocity, the Web Performance Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] GSoC: TeX rendering engine
Hi all, For those that are interested I have finally (now that my first batch of exams are finished) set-up a blog so that you can track the progress of the project. My blog can be found here: http://gsoc-mathtex.blogspot.com/ (no marks for originality ;). I intend to update it on a semi-regular basis, time permitting. Regards, Freddie. PGP.sig Description: This is a digitally signed message part -- Register Now Save for Velocity, the Web Performance Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Another Gnuplot style question
Matthias Michler wrote: Hello Eric, Hello list, a year ago I also encountered the problem of one file - one figure of the plotfile function. I would like to propose an addional functionality of using one figure and several files in plotfile, because sometimes I don't want to read data myself. I added a patch including the following changes: - added a new keywordargument to plotfile 'use_cf': If use_cf isTrue plotfile uses fig = gcf() instead of fig = figure() to suppress opening of a new figure and therewith allowing to use the user preferred figure - added a further new keyword argument 'names' to set x/ylabels in the case there are no names in the csv-file Furthermore I attached the modified plotfile_demo.py (examples/pylab_examples/plotfile_demo.py) and some new data (examples/data/data_x_x2_x3.csv). Could this be useful? Thanks in advance for any comments. Matthias, I incorporated a slight modification of your changes (newfig=False instead of use_cf=True) together with changes I made to directly support what Joseph asked about. The result is in r7078. I hesitated to make even these changes, though, because I think we should avoid trying to make plotfile into a do-all tool. It should be kept as something that may be handy for quick and dirty plotting in some situations; but when a user needs something beyond that, the better approach is for the user to simply use the pyplot or matplotlib API to achieve the desired result directly. Eric best regards Matthias On Wednesday 29 April 2009 09:20:17 Eric Firing wrote: Joseph Smidt wrote: Okay, I am another gnuplot user trying to migrate over to matplotlib. I like what I see, but there are a couple things that are very easy to do in Gnuplot that I can't figure out how to do with matplotlib. I have a file with 3 columns of data called data.txt that looks like: 0. 1. 1.0 0.0634 1.0655 1.1353 0.1269 1.1353 1.28899916094 0.1903 1.2097 1.46345358199 0.2538 1.2889 1.6615188369 0.3173 1.3734 1.88639043926 ... I can plot this data, 2 versus 1 and 3 versus 1, very easily on the same plot, with a legend, with log y values, and only for the xrange between 2 and 3 with gnuplot: set log y set xrange[2:3] plot 'data.txt' u 1:2 w l t 'apples', 'data.txt' u 1:3 w l t 'oranges' Now, how do I do that same thing with matplotlob? Ie: 1. Both graphs overlayed on the same plot. 2. Semilogy. (log y values), 3. Only ploy for x in the range 2-3. 4. Legend for the two graphs on same plot. Something like this: import numpy as np import matplotlib.pyplot as plt x, apples, oranges = np.loadtxt('data.txt', unpack=True) plt.semilogy(x, apples, label='apples') plt.semilogy(x, oranges, label='oranges') plt.legend() plt.gca().set_xlim(2, 3) plt.show() There are many possible variations and styles. The basic point is to separate reading in the data from plotting it. Plotfile won't do what you want because it is designed to make separate subplots instead of plotting multiple lines on a single axes. Maybe doing the latter would be at least as useful, if not more, and could be enabled as an option with one more kwarg. Eric I have spent time looking through the documentation but I can't find anyway to do this is any straightforward way. plotfile() looks promising, but I can't seem to make it do the above. Thanks in advance. Joseph Smidt --- --- Register Now Save for Velocity, the Web Performance Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Register Now Save for Velocity, the Web Performance Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Matplotlib interactive with gtk, gtkcairo, gtkagg backends
Hi everybody, For those of you that are using the gtk, gtkcairo, or gtkagg backends: Today pygtk version 2.15.0 became available, which is the first pygtk that can be used interactively from both python and ipython. If you're using ipython, be sure to wait for release 0.10.0 of ipython before upgrading to pygtk 2.15.0; older versions of ipython may not work correctly. If you're using regular python, you can install pygtk 2.15.0, set interactive to True in matplotlibrc, and you should be all set. Unfortunately, this won't work with IDLE; this is because of the lack of event loop support in Python itself. Enjoy! --Michiel. -- Register Now Save for Velocity, the Web Performance Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Enforcing common view limits
ax.twin returns a ParasiteAxesAuxTrans instance which is derived from the mpl's original Axes, but only drawing-related methods are meant to be meaningful. For example, this axes is never meant to be added to the figure and the draw method of this axes is never meant to be called. I haven't looked at it thoroughly but I guess the reason the callbacks are not processed is because this axes is not added to the figure and no set_xlim (or set_ylim) is explicitly called. However, consider it as a feature not a bug. The xlim of the parasite axes is mean to be only changed when the xlim of the host axes changes. And the set_xlim (and set_ylim) method should not be called directly on the parasite axes. Furthermore, I don't see any reason to connect xlim_change event to the parasite axes. If there is anything you want to do when the xlim of the parasite axes change, just connect it to the host axes. If there is a case that xlim_change event should be directly connected to the parasite axes (instead of the host axes), I'll consider it as a bug and try to fix it. Regards, -JJ On Sat, May 2, 2009 at 2:03 PM, Thomas Robitaille thomas.robitai...@gmail.com wrote: There was a typo in the script, the callbacks should be ax.name = first axis ax.callbacks.connect('xlim_changed',check_callback) ax.callbacks.connect('ylim_changed',check_callback) ax2 = ax.twin() ax2.name = second axis ax2.callbacks.connect('xlim_changed',check_callback) ax2.callbacks.connect('ylim_changed',check_callback) but the problem remains: check_callback is never called for ax2. Tom -- View this message in context: http://www.nabble.com/Enforcing-common-view-limits-tp23334325p23348806.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Register Now Save for Velocity, the Web Performance Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Register Now Save for Velocity, the Web Performance Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] hierarchical clustering with dendrograms in matplotlib?
hi all, is there a way to plot the results of hierarchical clustering as a dendrogram on top and to the sides of a heatmap matrix? for example, like this figure: http://www.egms.de/figures/meetings/gmds2006/06gmds075.f1.png any examples of how to do this in matplotlib would be greatly appreciated. thank you. -- Register Now Save for Velocity, the Web Performance Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users