[Matplotlib-users] Plotting data in real time
Hi, I'd like to use Python to plot data in real-time. I've created a GUI using wxPython and have embedded a Matplotlib graph into a pane. My problem is that I don't know the best way to update the graph. What's the recommended method for this? The data comes from a peripheral device connected to the PC, so I also need a way of regularly polling the hardware. I've managed this using a separate thread, but this doesn't work for updating the graph (Xlib complained). I'm sure this must be something that people have done many times before, but I've been unable to find a simple explanation on how to achieve it! Any help or suggestions would be much appreciated. Thanks, Rob - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Plotting data in real time
Robert Garrett schrieb: > Hi, > I'd like to use Python to plot data in real-time. I've created a GUI > using wxPython and have embedded a Matplotlib graph into a pane. My > problem is that I don't know the best way to update the graph. What's > the recommended method for this? First use the set_data (or set_xdata, set_ydata) methods of the artists which you might have created with the plot command. Then redraw the figure on screen using a .canvas.draw() call of your figure object. > The data comes from a peripheral device connected to the PC, so I also > need a way of regularly polling the hardware. I've managed this using > a separate thread, but this doesn't work for updating the graph (Xlib > complained). In wxPython changing the GUI should only happen from the main thread. Use wx.PostEvent with some user defined event object to send the newly aquired data from the acquisition thread to the main thread. In the event handling routine update the graph as described above. See the threading demo of the wxPython demo how to implement this. Gregor - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] New pgf backend for LaTex?
Hello, are there plan to implement a new backend for the latex proper use which create the drawing comand in the pgf language? With this kind of graphic creation I could overcome all the (font-) scaleing problems I have when I want to include a mpl graphic in my latex document. Even gnuplot has such an backend but I dont want to use it anymore :-) By, Friedrich - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] New pgf backend for LaTex?
On Friday 23 May 2008 10:35:14 am Friedrich Hagedorn wrote: > Hello, > > are there plan to implement a new backend for the latex proper use > which create the drawing comand in the pgf language? With this kind > of graphic creation I could overcome all the (font-) scaleing problems > I have when I want to include a mpl graphic in my latex document. I'm not familiar with pgf, could you provide some more information? What problems do you have with font scaling, and what additional capabilities do you think such an approach would offer? Darren - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] How is the size value used to generate symbols?
I'd like to plot values where the area of a marker is proportional to some value. How is the size value given in, say: scatter(x,y,'o',s=10) used to generate the markers? By eye it looks like the size value is proportional to the area (i.e. proportional to the radius squared for circle markers), but it would be nice to know for sure. Thanks, Neil - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] New pgf backend for LaTex?
> On Friday 23 May 2008 10:35:14 am Friedrich Hagedorn wrote: >> are there plan to implement a new backend for the latex proper use >> which create the drawing comand in the pgf language? With this kind >> of graphic creation I could overcome all the (font-) scaleing problems >> I have when I want to include a mpl graphic in my latex document. On Fri, 23 May 2008, Darren Dale wrote: > I'm not familiar with pgf, could you provide some more information? What > problems do you have with font scaling, and what additional capabilities do > you think such an approach would offer? PGF is the LaTeX portable graphics format, which can be used both with PDF production and DVI->PS production. It is a very nice innovation for LaTeX users, especially via its TikZ interface. PGF users get the full power of LaTeX for typesetting on their diagrams. This is great. For this reason, I often write PGF/TikZ code by hand when my graphs are simple. A PGF backend would be wonderful for LaTeX users who are producing documents for final distribution. All that said, I suspect the payoff to me personally would be modest, as I am almost always producting documents for later publication, at which point I generally need to provide EPS or PDF figures. If you are still interested, you may find the following to be useful: http://www.tug.org/pracjourn/2007-1/mertz/> hth, Alan Isaac - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] New pgf backend for LaTex?
On Fri, May 23, 2008 at 10:51:05AM -0400, Darren Dale wrote: > On Friday 23 May 2008 10:35:14 am Friedrich Hagedorn wrote: > > Hello, > > > > are there plan to implement a new backend for the latex proper use > > which create the drawing comand in the pgf language? With this kind > > of graphic creation I could overcome all the (font-) scaleing problems > > I have when I want to include a mpl graphic in my latex document. > > I'm not familiar with pgf, could you provide some more information? pgf is a tex-based graphic language similar to ps-tricks but also for pdftex. There are very nice graphics: http://www.ctan.org/get/graphics/pgf/base/doc/generic/pgf/pgfmanual.pdf The basic drawing is like this (a cross) \begin{tikzpicture} \draw (-1.5,0) -- (1.5,0); % horizontal line \draw (0,-1.5) -- (0,1.5); % vertical line \draw (1,1) node{$y=x^2$}; % text label \end{tikzpicture} There also exsits makro pakages for (more ore less convinent) data plots but then you dont have the nice python interface. > What problems do you have with font scaling, and what additional > capabilities do you think such an approach would offer? I want that fonts in the mpl graphics have the same (or otherwise related) proerties as the main-font in my latex document. So, therefore I have to know all the font properties from my latex document (\normalfont): type, family, size. The next problem is that the standard size of the mpl graphic (8, 6) inches is too big for my latex document (0.5\linewidth). Therefore I must scale the mpl graphic (\includegraphics[width=0.5\linewidth]{...}). But with this scaling the font in the mpl graphic are also scaled and I have no chance adapeting the two fonts (mpl, latex) without manual iterations. Ok, I could adjust the figsize but the last time I did it (long time ago) there were other misplaced objects in the mpl graphic (I dont remember exactly, sorry). But if I had the whole mpl graphic as pgf commands there would be no problem with the font stuff, scaleing and line widths. And may be you could extend the mpl graphic with some tricky (and eye candy) pgf extensions (ok I am also a beginner with the pgf language but its realy powerfull). BTW. In the same way I can create very nice ciruit schematic with CircuitMacros www.ece.uwaterloo.ca/~aplevich/Circuit_macros/html/examples.pdf I hope you could understand what I mean :-) By, Friedrich - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] New pgf backend for LaTex?
On Friday 23 May 2008 11:30:03 am Friedrich Hagedorn wrote: > On Fri, May 23, 2008 at 10:51:05AM -0400, Darren Dale wrote: > > On Friday 23 May 2008 10:35:14 am Friedrich Hagedorn wrote: > > > Hello, > > > > > > are there plan to implement a new backend for the latex proper use > > > which create the drawing comand in the pgf language? With this kind > > > of graphic creation I could overcome all the (font-) scaleing problems > > > I have when I want to include a mpl graphic in my latex document. > > > > I'm not familiar with pgf, could you provide some more information? > > pgf is a tex-based graphic language similar to ps-tricks but also > for pdftex. There are very nice graphics: > > http://www.ctan.org/get/graphics/pgf/base/doc/generic/pgf/pgfmanual.pdf > > The basic drawing is like this (a cross) > > \begin{tikzpicture} > \draw (-1.5,0) -- (1.5,0); % horizontal line > \draw (0,-1.5) -- (0,1.5); % vertical line > \draw (1,1) node{$y=x^2$}; % text label > \end{tikzpicture} > > There also exsits makro pakages for (more ore less convinent) data plots > but then you dont have the nice python interface. > > > What problems do you have with font scaling, and what additional > > capabilities do you think such an approach would offer? > > I want that fonts in the mpl graphics have the same (or otherwise related) > proerties as the main-font in my latex document. I understand this desire. John Hunter came up with the idea of the current latex support around the time that I was writing my dissertation. Like you note below, we sometimes have to iterate to get just what we want, but I think that is unavoidable. More below... > So, therefore I have to know all the font properties from my latex > document (\normalfont): type, family, size. > > The next problem is that the standard size of the mpl graphic (8, 6) inches > is too big for my latex document (0.5\linewidth). Therefore I must scale > the mpl graphic (\includegraphics[width=0.5\linewidth]{...}). But with this > scaling the font in the mpl graphic are also scaled and I have no chance > adapeting the two fonts (mpl, latex) without manual iterations. > > Ok, I could adjust the figsize but the last time I did it (long time ago) > there were other misplaced objects in the mpl graphic (I dont remember > exactly, sorry). > > But if I had the whole mpl graphic as pgf commands there would be no > problem with the font stuff, scaleing and line widths. And may be you > could extend the mpl graphic with some tricky (and eye candy) pgf > extensions (ok I am also a beginner with the pgf language but its > realy powerfull). Wouldn't this cause some problems with how the text is layed out on the canvas? The way it works now, a title can be centered over the axes because the extents of the text are known. If you allow the fonts and font sizes to be dictated by the latex document, they will end up being positioned incorrectly. P.S. please be careful that your responses go to the userlist - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How is the size value used to generate symbols?
Neil Crighton wrote: > I'd like to plot values where the area of a marker is proportional to > some value. How is the size value given in, say: > > scatter(x,y,'o',s=10) > > used to generate the markers? By eye it looks like the size value is > proportional to the area (i.e. proportional to the radius squared for > circle markers), but it would be nice to know for sure. Hi Neil, good eyes ;-) Have a look at the scatter documentation: "s is a size in points^2. It is a scalar or an array of the same length as x and y." Manuel > Thanks, > Neil > > - > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] New pgf backend for LaTex?
On Fri, May 23, 2008 at 05:30:02PM +0200, Friedrich Hagedorn wrote: > > The next problem is that the standard size of the mpl graphic (8, 6) inches > is too big for my latex document (0.5\linewidth). Therefore I must scale > the mpl graphic (\includegraphics[width=0.5\linewidth]{...}). But with this > scaling the font in the mpl graphic are also scaled and I have no chance > adapeting the two fonts (mpl, latex) without manual iterations. > > Ok, I could adjust the figsize but the last time I did it (long time ago) > there were other misplaced objects in the mpl graphic (I dont remember > exactly, sorry). I tried this now with (width = 7cm = 2.67in) In [1]: figure(figsize=(2.67,2)) Out[1]: In [2]: subplot(111) Out[2]: and the problem is that the remaining (abolute) space of the margin ist too small for the whole labeling (ticks and axis). But I dont want to adjust all the default values every time a what a plot in my latex document. On Fri, May 23, 2008 at 12:00:03PM -0400, Darren Dale wrote: > > Wouldn't this cause some problems with how the text is layed out on > the canvas? The way it works now, a title can be centered over the axes > because the extents of the text are known. If you allow the fonts and > font sizes to be dictated by the latex document, they will end up being > positioned incorrectly. Shortly: Yes this is a problem but pgf could solve it. I dont know it exactly but if you do all the graphic stuff with pgf in latex so you can adjust the text boxes in a various way in respect to different points. E.g. baseline -left, -right, -center and so on. This is explaind in the pgfmanual in section 53.3.3. If I fly over the pgfmanual I get the impression that I could do everything with it :-) But to do this its a hard work (for beginners). Therefore I like to have the convinient pylab-interface to create pretty standard plots for latex. By, Friedrich - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] New pgf backend for LaTex?
On Friday 23 May 2008 12:25:39 pm Friedrich Hagedorn wrote: > On Fri, May 23, 2008 at 05:30:02PM +0200, Friedrich Hagedorn wrote: > > The next problem is that the standard size of the mpl graphic (8, 6) > > inches is too big for my latex document (0.5\linewidth). Therefore I must > > scale the mpl graphic (\includegraphics[width=0.5\linewidth]{...}). But > > with this scaling the font in the mpl graphic are also scaled and I have > > no chance adapeting the two fonts (mpl, latex) without manual iterations. > > > > Ok, I could adjust the figsize but the last time I did it (long time ago) > > there were other misplaced objects in the mpl graphic (I dont remember > > exactly, sorry). > > I tried this now with (width = 7cm = 2.67in) > > In [1]: figure(figsize=(2.67,2)) > Out[1]: > > In [2]: subplot(111) > Out[2]: > > and the problem is that the remaining (abolute) space of the margin > ist too small for the whole labeling (ticks and axis). But I dont > want to adjust all the default values every time a what a plot in > my latex document. > > On Fri, May 23, 2008 at 12:00:03PM -0400, Darren Dale wrote: > > Wouldn't this cause some problems with how the text is layed out on > > the canvas? The way it works now, a title can be centered over the axes > > because the extents of the text are known. If you allow the fonts and > > font sizes to be dictated by the latex document, they will end up being > > positioned incorrectly. > > Shortly: Yes this is a problem but pgf could solve it. > > I dont know it exactly but if you do all the graphic stuff with pgf in > latex so you can adjust the text boxes in a various way in respect to > different points. E.g. baseline -left, -right, -center and so on. This is > explaind in the pgfmanual in section 53.3.3. > > If I fly over the pgfmanual I get the impression that I could do > everything with it :-) But to do this its a hard work (for beginners). > > Therefore I like to have the convinient pylab-interface to create pretty > standard plots for latex. I'll keep it in mind, but I have just committed myself to another mpl-related project for the summer, so I dont think I will have time to look into this for a while. But we love code submissions... - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users