Re: [Matplotlib-users] A request for a Matplotlib extension to hist
Hi, I think there is a good reason to add the functionality to plot pre-computed histograms to hist() or to a new function with similar API. Sometimes histograms are heavy or we don't want to recompute them to perform a series of plots. In this case, I miss the ability to easily set the plot style. hist() allows to chose between bar, step and stepfilled. To change the style with pre-computed histograms, I need to write 3 different "plots" using bar(), plot() and fill_between() respectively. This is quite inconvenient and error prone, considering that these function have different API for the input data. Maybe the plotting part of hist() should be splitted in a standalone function (plotbins() ?) In this way, hist() can call this function to generate the plot, but also the user can call it when the histogram is pre-computed. The bonus is that we retain the same API for plot style. My 2cents, Antonio On Fri, Apr 24, 2015 at 4:31 AM, Jerzy Karczmarczuk < jerzy.karczmarc...@unicaen.fr> wrote: > > Le 24/04/2015 12:58, Christian Alis responds to the problem posed by > Virgil Stokes > > I had the same problem some time ago and what I did is to use bar() to > > plot the histogram, which can be done in one line: > > > > hst, bin_edges = np.histogram(data) > > plt.bar(bin_edges[:-1], hst) > > > > Perhaps this trick can be added in the documentation? > > > > I am willing to code Virgil's request if many will find this useful. > Separating the computation of the histogram, and plotting it is > obviously useful. > (I needed this in a linguistical simulation context, where plotting had > no sense). > > Actually hist is more or less this, > see _axes.py, line 5678, the Axes method hist just calls > numpy.histogram. And then plots bars (or uses some other style). > > So, although completing the documentation might be of general interest, > I would NOT recommend adding some new version of hist. > This would be misleading. Hist is hist is hist(ogram). It computes the > histogram (and eventually plots it). If it is already computed elsewhere, > naming the procedure which JUST plots some bars a "histogram" is > methodologically very dubious. > > Jerzy Karczmarczuk > > > > -- > One dashboard for servers and applications across Physical-Virtual-Cloud > Widest out-of-the-box monitoring support with 50+ applications > Performance metrics, stats and reports that give you Actionable Insights > Deep dive visibility with transaction tracing using APM Insight. > http://ad.doubleclick.net/ddm/clk/290420510;117567292;y > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] mlab: computing power spectra
Thanks Paul, your explanation makes perfectly sense. Indeed, computing "manually" the PDS (using numpy.fft) in a test case gives me equal power for sine wave component of same amplitude, even when a component is in the highest frequency bin. However, giving the same test case to matplotlib.mlab.specgram() results in the power density of the highest frequency bin being higher than the other components. For the test see this notebook: http://nbviewer.ipython.org/gist/tritemio/162925a69a6ec29cdfe1 Antonio On Wed, Feb 11, 2015 at 8:50 PM, Paul Blelloch wrote: > I’m just answering off the top of my head, but it would seem to make sense > to me that neither the 0 frequency nor the fmax frequency should be scaled > by 2. If you take an FFT of a signal of length N, you’ll get a transform > of length N. N/2 points will correspond to positive frequencies, one point > to zero frequency and N/2-1 points to negative frequency. So it’s the > N/2-1 points that are reflected to the positive frequency axis, and the > fmax frequency is the only one that doesn’t have a corresponding point on > the negative axis. > > > > On the practical side, I’d say that you’re asking for trouble if you’re > looking at the last frequency bin in a power spectrum. If there’s any > significant energy in that bin, there’s almost certainly energy at higher > frequencies that’s being aliased down. You really need to make sure that > you have negligible power content before you get to the Nyquist frequency, > usually by applying an analog filter to the data, or otherwise knowing that > it cannot have undesired high frequency content. > > > > *From:* Antonino Ingargiola [mailto:trite...@gmail.com] > *Sent:* Wednesday, February 11, 2015 6:45 PM > *To:* matplotlib-users@lists.sourceforge.net > *Subject:* [Matplotlib-users] mlab: computing power spectra > > > > Hi to all, > > > > I'm computing some spectrograms using the convenient functions defined in > matplotlib.mlab. > > > > I found something that I don't completely understand. In computing the PSD > the onesided power spectrum is scaled by a factor of 2 except for the first > and the last bin: > > > > > https://github.com/matplotlib/matplotlib/blob/v1.4.2/lib/matplotlib/mlab.py#L776 > > > > in principle this should account for the contributions that in a two-sided > spectrum is spread over negative and positive frequencies. However the lack > of scaling in the highest frequency seems to cause a systematic > underestimation on that frequency bin. > > > > Is it possible that the power spectrum should be scaled, in the case of > even-length signal, up to the last bin (so that -1 in the slicing should be > removed)? > > > > With correct scaling a signal comprised of two sinusoids of same power, > one being at the Nyquist frequency, should have the same amplitude > (excluding scallopping losses). I don't have time to test it at the moment, > but maybe someone more expert can already tell me if I'm missing something > or the matplotlib scaling is wrong. > > > > Thanks, > > Antonio > -- Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] mlab: computing power spectra
Hi to all, I'm computing some spectrograms using the convenient functions defined in matplotlib.mlab. I found something that I don't completely understand. In computing the PSD the onesided power spectrum is scaled by a factor of 2 except for the first and the last bin: https://github.com/matplotlib/matplotlib/blob/v1.4.2/lib/matplotlib/mlab.py#L776 in principle this should account for the contributions that in a two-sided spectrum is spread over negative and positive frequencies. However the lack of scaling in the highest frequency seems to cause a systematic underestimation on that frequency bin. Is it possible that the power spectrum should be scaled, in the case of even-length signal, up to the last bin (so that -1 in the slicing should be removed)? With correct scaling a signal comprised of two sinusoids of same power, one being at the Nyquist frequency, should have the same amplitude (excluding scallopping losses). I don't have time to test it at the moment, but maybe someone more expert can already tell me if I'm missing something or the matplotlib scaling is wrong. Thanks, Antonio -- Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Line update: set_data vs recache issue
Hi to all, I'm doing a simple animation like this: -- ion() x = arange(0,2,0.01) y = zeros_like(x) y[45:55]=1 l, = plot(x,y) D = 0.1 h = x[1]-x[0] dt = 0.0001; def nabla(v,h): na = zeros_like(v) na[1:-1] = (v[2:]-2*v[1:-1]+v[:-2]) na[0],na[-1] = 0,0 return na/(h**2) for i in range(1000): y = y + D*nabla(y,h)*dt if i%10 == 0: l.set_ydata(y) draw() -- however, changing the line y = y + D*nabla(y,h)*dt with in y += D*nabla(y,h)*dt the plot is not updated anymore. I have to replace l.set_ydata(y) with y.recache() to make the the animation work again. I think this is a bug since the line should be updated even using the += operator. Regards, Antonio -- Return on Information: Google Enterprise Search pays you back Get the facts. http://p.sf.net/sfu/google-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] animation/"live"-plotting + performance
Hi, 2009/7/29 Jae-Joon Lee : > On Tue, Jul 28, 2009 at 9:11 AM, Roland Koebler wrote: [cut] >> Any ideas? >> > > http://matplotlib.sourceforge.net/examples/animation/animation_blit_gtk2.html > > The above example does something similar to (b). > It saves the previous plot (only axes area is saved) as a bitmap. In > next run, it restores the saved bitmap after shifting. And then draw > only the new data points. > > The example requires the svn version of matplotlib. I have attached another example of blit animation that does NOT require the svn version of MPL. Antonio #!/usr/bin/env python """ This an example script that shows how to do a Matplotlib blit animation in a Gtk2 window. The script shows howto to bind to the MPL 'draw_event' in order to make the blit animation working with padnning/zooming and window resizing. Furthermore the MPL navigation toolbar is modified through the addition of two custom buttons. 2009 (C) Antonino Ingargiola Licence: GNU GPL v2 or later. """ from time import sleep import gtk import gobject import numpy as np from matplotlib.figure import Figure from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as NavigationToolbar ## # Simple GTK windows base classes # class BaseWindow: """A base gtk window that can be closed.""" def __init__(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_default_size(550, 500) self.window.connect("delete_event", self.on_delete_event) self.window.connect("destroy", self.on_destroy) def main(self): gtk.main() def on_delete_event(self, widget, *args): return False def on_destroy(self, widget, data=None): gtk.main_quit() class PlotWindow(BaseWindow): """A gtk window with a figure inside.""" def __init__(self, show=True, create_axis=False): BaseWindow.__init__(self) self.figure = Figure() self.canvas = FigureCanvas(self.figure) if create_axis: self.ax = self.figure.add_subplot(111) self.toolbar = NavigationToolbar(self.canvas, self.window) self.vbox = gtk.VBox() self.vbox.pack_start(self.toolbar, expand=False) self.vbox.pack_start(self.canvas, expand=True) self.window.add(self.vbox) if show: self.window.show_all() ## # The main application # class Plotter(PlotWindow): def __init__(self): PlotWindow.__init__(self, create_axis=True, show=False) # Now we have self.canvas, self.figure and self.ax correctly assigned # Let add two buttons to the toolbar: scale and play self.scalebutton = gtk.ToolButton(gtk.STOCK_ZOOM_FIT) self.scalebutton.connect("clicked", self.scale_clicked) self.toolbar.insert(self.scalebutton, 0) self.playbutton = gtk.ToggleToolButton(gtk.STOCK_MEDIA_PLAY) self.playbutton.set_active(False) self.playbutton.connect("clicked", self.play_toggled) self.toolbar.insert(self.playbutton, 0) self.window.show_all() # Now create the plot of the first frame (note: animated=True) self.t = np.arange(100)*0.1 self.line, = self.ax.plot(self.t, np.sin(self.t), animated=True) self.ax.grid(True) # Connect the callback for the draw_event self.cid = self.canvas.mpl_connect('draw_event', self.ax_redraw) # Start the gtk main loop self.n = 0 self.main() def ax_redraw(self, widget=None): # Redraw the axis self.ax.draw() # Save the new background for the animation self.background = self.canvas.copy_from_bbox(self.ax.bbox) # The animated line needs to be drawn explicitly self.draw_line() def canvas_redraw(self): # Disconnect the 'draw_event' callbak to avoid recursion self.canvas.mpl_disconnect(self.cid) # Completely canvas redraw self.canvas.draw() # Reconnect the 'draw_event' callback self.cid = self.canvas.mpl_connect('draw_event', self.ax_redraw) # Save the new background for the animation self.background = self.canvas.copy_from_bbox(self.ax.bbox) # The animated line needs to be drawn explicitly self.draw_line() def draw_line(self): # Draw the line into the axis self.ax.draw_artist(self.line) self.canvas.blit(self.ax.bbox) def update_plot(self): """The fast (blit) update to be used in animations.""" self.n += 1 # Restore the clean slate background self.canvas.restore_region(self.background) # Update the line d
[Matplotlib-users] Gtk blit animation, best practices
HI to the list, I'm playing with blit animations in a gtk window. Looking at MPL examples I came up with a working example (attached) that shows a sin wave with a play toggle button and a "scale" button that changes the axis limits. In order to plot the first frame (before play is clicked) and to correctly implement the scale action I've written the "refresh" method that follows: def refresh(self): # This explicit draw is needed to draw the grid and to save a clean # background self.canvas.draw() self.background = self.canvas.copy_from_bbox(self.ax.bbox) # This draw is needed to draw the stand-still plot (first frame) self.line.set_animated(False) self.canvas.draw() self.line.set_animated(True) # NOTE: Saving the background here would save the line too so I have # to call canvas.draw() two times This (quite redundant) implementation works. However, (QUESTION 1) is it expected that the following straightforward implementation: def refresh(self): self.line.set_animated(False) self.canvas.draw() self.line.set_animated(True) self.background = self.canvas.copy_from_bbox(self.ax.bbox) saves in background also the line? So in this case I would have the animation superimposed to the first frame? Seems like a bug... Is there a better way to achieve the same result? Furthermore, I want to attach the refresh method to some events in order to refresh the plot event if play is not active. For example zooming or panning with the matplotlib toolbar buttons makes the plot disappear. (QUESTION 2) Is there such event I can use to have the line plotted? Or is better to implement this changing from an animated to a still state? In this latter case once I plot with animated=False I'm not able anymore to save a clean background without the line (event using the line.set_animated(True) method before copying the bg). When we have solved this file could be a nice reference example. Thanks, ~ Antonio #!/usr/bin/env python import gtk import gobject import numpy as np from matplotlib.figure import Figure from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as NavigationToolbar ## # Simple GTK windows base classes # class BaseWindow: """A base gtk window that can be closed.""" def __init__(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_default_size(550, 500) self.window.connect("delete_event", self.on_delete_event) self.window.connect("destroy", self.on_destroy) def main(self): gtk.main() def on_delete_event(self, widget, *args): return False def on_destroy(self, widget, data=None): gtk.main_quit() class PlotWindow(BaseWindow): """A gtk window with a figure inside.""" def __init__(self, show=True, create_axis=False): BaseWindow.__init__(self) self.figure = Figure() self.canvas = FigureCanvas(self.figure) if create_axis: self.ax = self.figure.add_subplot(111) self.toolbar = NavigationToolbar(self.canvas, self.window) self.vbox = gtk.VBox() self.vbox.pack_start(self.toolbar, expand=False) self.vbox.pack_start(self.canvas, expand=True) self.window.add(self.vbox) if show: self.window.show_all() ## # The main application # class Plotter(PlotWindow): def __init__(self): PlotWindow.__init__(self, create_axis=True, show=False) # Add two buttons to the toolbar: scale and play self.scalebutton = gtk.ToolButton(gtk.STOCK_ZOOM_FIT) self.scalebutton.connect("clicked", self.scale_clicked) self.toolbar.insert(self.scalebutton, 0) self.playbutton = gtk.ToggleToolButton(gtk.STOCK_MEDIA_PLAY) self.playbutton.set_active(False) self.playbutton.connect("clicked", self.play_toggled) self.toolbar.insert(self.playbutton, 0) self.window.show_all() # Create the plot, the first frame (note that animated=True) self.t = np.arange(100)*0.1 self.line, = self.ax.plot(self.t, np.sin(self.t), animated=True) self.ax.grid(True) # Finalize the plot self.refresh() self.n = 0 self.main() # Start the gtk main loop def refresh_wrong(self): self.line.set_animated(False) self.canvas.draw() self.line.set_animated(True) self.background = self.canvas.copy_from_bbox(self.ax.bbox) def refresh(self): # This explicit draw is needed to draw the grid and to save a clean # background self.canvas.draw() self.background = self.canvas.copy_from_bbox(self.ax.bbox) # This draw is needed to draw the stand-still plot (first frame) self.line.set_animated(False) self.canvas.draw()
Re: [Matplotlib-users] 2 newbie questions: redraw plot and access to raw image buffer
Hi, 2007/10/29, Darran Edmundson <[EMAIL PROTECTED]>: > > I'm trying to generate plots as textures for use within a real-time > graphics application (written using the pythonOgre graphics engine). > I'm brand new to matplotlib so please bear with me. Two questions, one > easy, one possibly hard. > > In the following code snippet, I create and draw a pie chart, do some > intermediate work, update the pie fractions, and redraw. I end up with > the second version superimposed on the first. Initially I thought it > was simply a matter of clearing the canvas, but as I repeat this test > with more and more updates, the redraw seems to slow down - this makes > me think that each redraw is actually rerendering all the layers. Is > this the case? If so, how do I avoid it? > > # create matplotlib figure > figure = Figure(figsize=(4,3), dpi=200, frameon=True) > figureCanvas = FigureCanvas(figure) > > # unchanging details of pie chart > ax = figure.add_subplot(111) # pie plot > labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' > ax.set_title('Example pyOgre Pie Chart') > ax.grid(True) > ax.pie([25,25,30,20], labels=labels) > figureCanvas.draw() > > # > > # update pie chart At this point I guess you can do ax.clear() to clear the axis and delete all the old plots. > ax.pie([30,25,25,20], labels=labels) > > # matplotlib draw > figureCanvas.draw() > > > > And the harder question. I need access to the address of the raw image > buffer. (I assume this is a contiguous block of c-allocated memory?) > Presently, I copy into a ctypes buffer but this slows things down > significantly. Is there an alternative approach? Sorry I can't help with this :-/. Regards, ~ Antonio - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Filtering plots
You can do it this way: data = array(data) x = arange(len(data)) plot(x[data!=0], data[data!=0]) Regards, ~ Antonio - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Graphic properties editing
Hi, 2007/6/19, John Hunter <[EMAIL PROTECTED]>: > * you may want to look at the line editor dialog in backend_gtk.py for > inspiration. This uses drop down menus for linestyles, color dialog > boxes to pick colors, etc... I'll paste in the code below > > Thanks, > JDH > > class DialogLineprops: Just for the record, I had to explicitly import gtk.glade and to put a self.show() call in the __init__() method to make this work. Nice example though. Thanks :). Regards, ~ Antonio - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Graphic properties editing
Hi, 2007/6/19, Antoine Sirinelli <[EMAIL PROTECTED]>: > On Tue, Jun 19, 2007 at 02:12:28PM +0200, David Tremouilles wrote: > > Pyplotsuite is another pygtk project using matplotlib. > > It is developed by Antonino Ingargiola. > > http://pyplotsuite.sourceforge.net/ > > Could be maybe interesting to join the effort on providing nice pygtk > > tools for matplotlib sharing common elements of this two projects. > > Just a suggestion... > > Interesting project. Thanks for the link, I didn't know this project. Because has not been announced anywhere yet :D. Antoine, I like the idea of your script. I really would like to see a such thing included in matplotlib eventually. It would help either to quick modify *all* the plot parameters and to have an immediate visual representation of the matplotlib hierarchies. So would help both matplotlib script's users and (matplotlib) programmers as well. As suggestion I think would be useful to divide the properties in three groups: free text, number and list and use for each of then a text entry, a spin button or a combo box. Don't be offended if this is obvious to you :). I've implemented a somewhat similar dialog for Plotfile2 (one of the two scripts composing PyPlotSuite). My dialog although "similar" is more limited in scope. If you are interested you can see the dialog class here (line 566): http://repo.or.cz/w/pyplotsuite.git?a=blob;f=plotfile2.py;h=aa089c3e09957d36396e4f3b97fbfb38d58c44de;hb=HEAD and a screenshot to see how it looks like: http://pyplotsuite.sourceforge.net/images/plotfile2-screenshot2.png I will use your implementation and John Hunter's DialogLineprops as source of inspiration. Thanks... > > I'm very pleased to see there is an active and growing community using > > matplotlib together with pygtk. > > I am using pygtk and matplotlib in my work for building interfaces to > data analysis programs (numpy, scipy and C). I've do this for my own purpose. After a while I decided to publish some of my scripts so PyPlotSuite was born. The purpose is to allow the user to visualize/analyze data without knowing python or matplotlib. Ideally my scripts would be associated to specific file types so that the file manager opens the data with the correct "visualizer" (at least this is how I use them). I'm open in any kind of collaboration, in both senses. I'm just a bit limited in time ATM. Regards, ~ Antonio - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] log scale
Hi, 2007/5/31, Navid Parvini <[EMAIL PROTECTED]>: > Dear All, > > How can I set the x-axis and/or y-axis in Log scale. In interactive mode: plot([1, 1e1, 1e2], [1, 1e1, 1e2]) ax = gca() ax.set_xscale('log') ax.set_yscale('log') draw() The other parameter .set_xscale and set_yscale accept is 'linear' for, surprisingly enough, linear scale. Regards, ~ Antonio - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] figure dpi output problem
Hi, 2007/5/26, Steve Schmerler <[EMAIL PROTECTED]>: > Jeff Whitaker wrote: > > [EMAIL PROTECTED] wrote: [cut] > > I get a 600x300 png with that script, using the latest SVN. > > > > -Jeff > > > > Me too, on Linux, mpl 0.90dev3131. Me too with MPL 0.87.7 on Debian Etch. ~ Antonio - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Setting axes at the origin
Hi, 2007/5/24, Michael Hogue <[EMAIL PROTECTED]>: > Hi, > > I'm wondering how to use matplotlib to > plot on axes that intersect at the > origin, as in the following picture: > > | > | > | > | > |(0,0) > > | > | > | > | > | > For example with: axis((-1,1,-1,1)) hlines(0,-1,1) vlines(0,-1,1) Regards, ~ Antonio - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplolib equivalent of gnuplot's impulse
2007/5/11, John Hunter <[EMAIL PROTECTED]>: > On 5/3/07, Emmanuel <[EMAIL PROTECTED]> wrote: > > With gnuplot one can do a plot like that : > > > > http://www.deqnotes.net/gnuplot/images/impulses.png > > > > It is using option "with impulse". > > Is there an equivalent in matplotlib? > > > In [5]: t = arange(0.0, 2.0, 0.05) > > In [6]: s = sin(2*pi*t) > > In [7]: vlines(t, 0, s) > Out[7]: http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Fwd: matplolib equivalent of gnuplot's impulse
Fowarding to the list ... -- Forwarded message -- From: Antonino Ingargiola <[EMAIL PROTECTED]> Date: 4-mag-2007 11.12 Subject: Re: [Matplotlib-users] matplolib equivalent of gnuplot's impulse To: Emmanuel <[EMAIL PROTECTED]> Hi, On 5/3/07, Emmanuel <[EMAIL PROTECTED]> wrote: > With gnuplot one can do a plot like that : > > http://www.deqnotes.net/gnuplot/images/impulses.png > > It is using option "with impulse". > Is there an equivalent in matplotlib? Maybe not directly as a "plot style". But... If you need to fill the curve with a color you can see this example: http://matplotlib.sourceforge.net/screenshots/fill_demo.py If you need the "bar" itself you can use the bar() function. If you need impulses composed by just "a line" you can use this function: def impulse(X, Y, color='blue', **kwargs): """Plot an "impulse" graph similar to the gnuplot 'impulse' function.""" if len(X) != len(Y): raise ValueError, "X and Y data must be of the same length." ax = gca() for x, y in zip(X, Y): ax.plot([x, x], [0, y], color=color, **kwargs) You can pass to it any plot() keyword-argument to customize line style. Cheers, ~ Antonio - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Getting data from a figure
On 3/30/07, Richard Brown <[EMAIL PROTECTED]> wrote: > On 30/03/07, [EMAIL PROTECTED] > <[EMAIL PROTECTED]> wrote: > > > > Not sure what region[:] is supposed to achieve. You are creating a copy > > with the same name, so you are over-riding the original variable. > > > > That doesn't seem to be the case - it returns the right thing on the > first call - i.e. region got changed, but on subsequent calls the > figure is displayed and the function returns array([0,0,0,0]). I > thought taking the slice just gave access to the internals of region > ... > > How does one assign a new value to a variable in a containing scope? You can declare the "region" variable as global in keypressed(): def keypressed(event): global region region = ... and "region" does not need to get initialized in the containing scope. Cheers, ~ Antonio - 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.php&p=sourceforge&CID=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 4/1/07, Antonino Ingargiola <[EMAIL PROTECTED]> wrote: > On 3/29/07, Ken McIvor <[EMAIL PROTECTED]> wrote: [cut] > > > 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(). > > That doesn't help :(. I'm not jet able to update the colorbar once the > image has changed. I've found a way to update the colorbar after the image has changed: image = imshow(data) colr_bar = colorbar() ... image.set_data(new_data) image.changed() color_bar.set_clim(vmax=newdata.max()) draw() The autoscale() colorbar method does not work to update a colorbar, but with the above code I can acheive the same result. Thanks again. ~ Antonio - 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.php&p=sourceforge&CID=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)
Sorry for the late answer... On 3/29/07, Ken McIvor <[EMAIL PROTECTED]> wrote: > 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. > > > > > 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? Good idea. I will try it next time I'll do something with GUI and 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. Thanks for the explanation, it's clear now :). > > 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. Good to know that this way is too tricky (at least). > > 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(). That doesn't help :(. I'm not jet able to update the colorbar once the image has changed. I will open a new thread to discuss this problem. > Ken ~ Antonio - 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.php&p=sourceforge&CID=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 3/28/07, Ken McIvor <[EMAIL PROTECTED]> wrote: > On Mar 27, 2007, at 12:35 PM, Antonino Ingargiola wrote: [cut] > 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. 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). 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. 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. Basically, I don't know which is the right way to put a Gtk GUI in background, while another thread get the data asynchronously. 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. > > 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. 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!). 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). Any hints? Many thanks so far... Ciao, ~ Antono PS: Here it is the script: from time import sleep from random import randint from pylab import * N = 5 def fake_data_generator(): sleep(randint(1,3)/10.0) return rand()*100 def data_aquisition_loop(): data = zeros((N,N)) for j in range(N): for i in range(N): print ' - Acquiring pixel (',i,',',j,') ... ' data[j,i] = fake_data_generator() plot_update(data) return data def setup_plot(data): global image, color_bar title('Scanning Data') image = imshow(data, interpolation='nearest', origin='upper', extent=[0,N,N,0]) color_bar = colorbar() def plot_update(data): image.set_data(data) color_bar.set_array(data) color_bar.autoscale() draw() if __name__ == '__main__': ion() setup_plot(rand(N*N).reshape(N,N)) data_aquisition_loop() - 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.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] creating live plot (update while data is arriving)
Hi to the list, 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. 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. 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). 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. 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. Ideally the plot should be performed in background, while the script goes on and wait the next data arrival. 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: class PlotScanApp: ... class GuiThread(threading.Thread): def run(self): gtk.main() if __name__ == '__main__': stdout = sys.stdout a = array(randn(100)).reshape(10,10) p = PlotScanApp(a) p.start() print 'Start image update:' for i in range(10): sleep(1) stdout.write('.') stdout.flush() p.plot(array(randn(100)).reshape(10,10)) 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... Any hints in how to do in the right way this gtk app that when required update the plot? Thank a lot. Ciao, ~ Antonio #!/usr/bin/env python # -*- coding: UTF8 -*- # Generic imports import sys import gtk import gtk.glade from pylab import * # Import some matplotlib widgets or functions from matplotlib.figure import Figure # Import from matplotlib the FigureCanvas with GTKAgg backend from matplotlib.backends.backend_gtkagg \ import FigureCanvasGTKAgg as FigureCanvas # Import the matplotlib Toolbar2 from matplotlib.backends.backend_gtk \ import NavigationToolbar2GTK as NavigationToolbar import threading from time import sleep # Global variables homepath = '/home/anto/python/' gladefile = homepath+'microlib.glade' class PlotScanApp: """ This class implements the Plot Scan Window. """ def __init__(self, data, debug=False): # Data self.data = data self.debug = debug self.plot_kwargs = dict( linestyle = '-', linewidth = 1.5, marker = '.', alpha = 1 ) # Plot Defaults self.title = title self.xlabel = 'X Axis' self.ylabel = 'Y Axis' self.xscale = 'linear' self.yscale = 'linear' self.showPoints = True self.showLines = True self.grid = True # Load the GUI description self.windowname = 'PlotScanWindow' self.widgetTree = gtk.glade.XML(gladefile, self.windowname) self.window = self.widgetTree.get_widget(self.windowname) # Create the figure, the axis and the canvas self.figure = Figure() self.axis = self.figure.add_subplot(111) self.canvas = FigureCanvas(self.figure) # Add the canvas to the container self.container = self.widgetTree.get_widget('CanvasAlignment') self.container.add(self.canvas) # Create the matplotlib toolbar self.toolbar = NavigationToolbar(self.canvas, self.window) toolbar_container = self.widgetTree.get_widget('ToolbarAlignment') toolbar_container.add(self.toolbar) self.widgetTree.signal_autoconnect(self) self.window.show_all() self.plot() def start(self): self.thread = GuiThread() self.thread.setDaemon(True) self.thread.start()
Re: [Matplotlib-users] Multiple plots
On 3/16/07, Niklas Saers <[EMAIL PROTECTED]> wrote: > Hi, > I'm quite new to Matplot. When issuing show() from Python 2.5 under > OS X I get a nice menu bar at the bottom with home, left, right etc. > How can I use these? I tried the different examples, and there are > plenty of examples that open multiple windows (such as > legend_auto.py) and that put multiple subplots in a plot, but none > that actually use the arrows. How can I put multiple plots into a > window that can be navigated using these arrows? Those arrows are meant to navigate through the various zoom level you have chosen with the zoom tool (click on the zoom button the select a rectangle with the left mouse button to zoom in, with the right mouse button to zoom out). Home returns to the first zoom level. > Cheers > > Niklas Cheers, ~ Antonio - 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.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Question about imshow and matshow
On 3/15/07, Pellegrini Eric <[EMAIL PROTECTED]> wrote: > Hello everybody, > > when using matplotlib, any plot I create is displayed separately from my > Tkinter application. Is there a direct way to embed the plot created by > matplotlib in a widget such as a canvas using something like "create_image" > or something else ? > > Currently, the only thing I managed to do is: > -create my plot with matshow > -save the figure using savefig (png) > -embed the png in a canvas using create_image > > not very smart, isn't it ? Definitely not ;). It's simple to embed matplotlib in the common toolkits. Download the examples tarball from the matplotlib site and look at the files embedding_in_XXX.py. There are examples for tk, gtk, qt and wx toolkits. > Thank you very much > > best regards > > Eric Pellegrini ~ Antonio - 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.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib, math greek letters and latex
On 3/14/07, Antonino Ingargiola <[EMAIL PROTECTED]> wrote: [cut] Furthermore I have noted that with "usetex" ticks label are rendered differently if they are explicitly set with set_[xy]ticklabels() or not. Compare the ytick labels (automatic) and xtick labels (manually set) in the attached plot. Now its attached, provided that attachments can reach the list. ~ Antonio image.eps.bz2 Description: BZip2 compressed data - 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.php&p=sourceforge&CID=DEVDEV___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib, math greek letters and latex
On 3/13/07, John Travers <[EMAIL PROTECTED]> wrote: > On 13/03/07, Antonino Ingargiola <[EMAIL PROTECTED]> wrote: [cut] > > However the only font I know that has the superscript with the minus > > sign is "DejaVu Sans". Anyone know a serif font (or also another sans > > font) with all those symbols? > > DejaVu Serif appears to, and both FreeSans and FreeSerif from freefont > project do. On my system (Ubuntu Dapper, matplotlib 0.87) the fonts DejaVu Sans and FreeSerif show the minus superscript in matplotlib plots, while FreeSans and DejaVu Serif no (they show an empty square). BTW, FreeSerif is quite good for my needs, thanks :). > John Cheers, ~ Antonio PS: John Travers, sorry for the private replies to you too. - 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.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib, math greek letters and latex
On 3/13/07, John Hunter <[EMAIL PROTECTED]> wrote: > On 3/13/07, Antonino Ingargiola <[EMAIL PROTECTED]> wrote: > > > 1. Use the unicode string: xlabel(u'Wavelength [μm]') > > 2. Use mathtext: xlabel(r'$\rm{Wavelength [\mu m]}$') > > 3. Use usetex: rc(text, usetex=True), xlabel(r'Wavelength [$\rm{\mu m}$]') > > > > I have some problem with each method (any hint is appreciated). > > What is the problem with method 3? The \mu character is not in roman font but in italics, while the 'm' is correctly set to roman. In latex I use the SIunits package to write the units, so the fonts are correctly in roman even in math environment. It would be useful something like that in matplotlib too. However I'll be happy even if I could write greek characters in roman fonts. Maybe it's a problem related to the particular font used... Furthermore font rendering it's a bit odd: the fonts appears to be bolder than normal Computer Modern fonts used in the latex document. I've tried to change the font weight (in matplotlibrc) without any effect. On the contrary mathtext seems to use a font like Times, which should be bolder, but the overall aspect is lighter. How can I change the font used by 'mathtext' or 'usetex'? All I want is use the standard ae fonts I'm using in latex. Many thanks. > JDH > Cheers, ~ Antonio - 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.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib, math greek letters and latex
On 3/13/07, Edin Salkovic <[EMAIL PROTECTED]> wrote: > Hi Antonino, > > If your using the version 0.90 (or SVN) of matplotlib you can also use > mathtext2. > > To enable it, put these lines in your matplotlibrc file: > mathtext.mathtext2 : True > mathtext.nonascii : FreeSerif.ttf # Or any unicode font > > or, you can set it for your particular script: > rcParams['mathtext.mathtext2'] = True > rcParams['mathtext.nonascii'] = 'FreeSerif.ttf' Interesting, I will try it when I have time to fiddle with 0.90 installation (currently I have 0.87, included in ubuntu dapper). > You can also set: > mathtext.rm : FreeSerif.ttf # Roman font > mathtext.it : FreeSerifItalic.ttf # Text italic > mathtext.tt : FreeMono.ttf# Typewriter (monospaced) > mathtext.mit: FreeSerifItalic.ttf # Math italic > mathtext.cal: FreeSansOblique.ttf # Caligraphic > > Beware that you have to have the freefonts installed on your system, > or in the mpl data-dir. Nice, thanks for the imformation. Do they work in matplotlib 0.87 too? (In my quick test they do not work). Currently I'm not able to change mathtext or "usetex" fonts (except for the font size). The font.serif, font.sans, etc... properties change only the normal text font. Furthermore I have noted that with "usetex" ticks label are rendered differently if they are explicitly set with set_[xy]ticklabels() or not. Compare the ytick labels (automatic) and xtick labels (manually set) in the attached plot. You can see also that the title and x axis label fonts are "boldier" (weightier) than the standard latex Computer Modern fonts (the difference become evident when the image is included in a latex document). This effect is what I was talking about in previous mail. > Best, > Edin Ciao, ~ Antonio PS: Sorry to Edin Salkovic for previous private reply - 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.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib, math greek letters and latex
On 3/13/07, John Travers <[EMAIL PROTECTED]> wrote: > On 13/03/07, Antonino Ingargiola <[EMAIL PROTECTED]> wrote: > > 1. This method works ok as far as I choose a unicode font with the > > greek letters, for example: > > > > rcParams['font.serif'] = 'DejaVu Serif' > > > > However with unicode strings I'm not able to do exponent and deponent > > text (i.e cm^-1) > > You should be able to do super/subscripts in unicode. For example a > superscript '-' is unicode 207B. If you haven't already found it you > should check out: > http://unicode.org/charts/symbols.html > for more codes. However, the font you choose must support the unicode > (most only support a certain subset). Many thanks. Now I can do superscript and subscript (using GuCharMap I can search in symbol description so it's easy to find them). However the only font I know that has the superscript with the minus sign is "DejaVu Sans". Anyone know a serif font (or also another sans font) with all those symbols? Cheers, ~ Antonio PS: Sorry to John Hunter my previous private reply - 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.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib, math greek letters and latex
Sorry for the previous mail I've hit Send for error before the mail was complete. Here it is the complete mail: Hi to the list, I'm using matplotlib to generate graphs during my master thesis. I want to thank all the developer for providing such flexible tool. In some plots I have to put greek letters (or sometimes small formulas) as axis label. I've found three way to accomplish this: 1. Use the unicode string: xlabel(u'Wavelength [μm]') 2. Use mathtext: xlabel(r'$\rm{Wavelength [\mu m]}$') 3. Use usetex: rc(text, usetex=True), xlabel(r'Wavelength [$\rm{\mu m}$]') I have some problem with each method, any hint is appreciated. 1. This method works ok as far as I choose a unicode font with the greek letters, for example: rcParams['font.serif'] = 'DejaVu Serif' However with unicode strings I'm not able to do exponent and deponent text (i.e cm^-1) Methods 1. and 2. are more flexible, however I'm no able to to put the \mu character in roman fonts. I don't know if this is the intended behavior or if it's a bug... Furthermore, is there a simple way to set fontsize for all text elements (labels, title, ticklabels). Currently I'm doing: rcParams['font.size'] = 12 rcParams['xtick.labelsize'] = 14 rcParams['axes.titlesize'] = 16 rcParams['axes.labelsize'] = 14 The relative setting (large, small,...) seems to refer always to the default font size (set in matplotlibrc). Is there a way to set the font.size property and then update all the other relative values to reflect the change? Many thanks for any help. ~ Antonio - 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.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] matplotlib, math greek letters and latex
Hi to the list, I'm using matplotlib to generate graphs during my master thesis. I want to thank all the developer for providing such flexible tool. In some plots I have to put greek letters (or sometimes small fomulas) as axis label. I've found three way to accomplish this: 1. Use the unicode string: xlabel(u'Wavelength [μm]') 2. Use mathtext: xlabel(r'$\rm{Wavelength [\mu m]}$') 3. Use usetex: rc(text, usetex=True), xlabel(r'Wavelength [$\rm{\mu m}$]') I have some problem with each method (any hint is appreciated). 1. This method works ok as far as I choose a unicode font with the greek letters, for example: - 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.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users