Re: [Matplotlib-users] pylab axis query and possible bug
Beautiful! Many thanks John. Gary R. John Hunter wrote: > You can manually turn off autoscaling on the axes instance with the > following, and both scatter and plot should then work as you want. > > ax1 = subplot(121) > axis('off') > ax1.imshow(rand(20,20)) > ax2 = subplot(122) > axis('off') > ax2.imshow(rand(20,20)) > > ax1.set_autoscale_on(False) > #ax1.scatter([5,10],[5,10])# note 2 > ax1.plot([5,10],[5,10], 'o') # note 3 > show() - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. 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] py2exe problem
Dear Werner, I tested your script here here with python 2.5, matplotlib 0.91.1 and wxpython 2.8.7.1 using regular installation (not enthought). If I replace : from wx import * by import wx (and make the necessary modification) The program starts well! (the button does not work but the problem is already present when running directly the python script) #!/usr/bin/env python # embedding_in_wx.py # """ Copyright (C) Jeremy O'Donoghue, 2003 License: This work is licensed under the PSF. A copy should be included with this source code, and is also available at http://www.python.org/psf/license.html This is a sample showing how to embed a matplotlib figure in a wxPanel. The example implements the full navigation toolbar, so you can automatically inherit standard matplotlib features such as the ability to zoom, pan and save figures in the supported formats. There are a few small complexities worth noting in the example: 1) By default, a wxFrame can contain a toolbar (added with SetToolBar()) but this is at the top of the frame. Matplotlib default is to put the controls at the bottom of the frame, so you have to manage the toolbar yourself. I have done this by putting the figure and toolbar into a sizer, but this means that you need to override GetToolBar for your wxFrame so that the figure manager can find the toolbar. 2) I have implemented a figure manager to look after the plots and axes. If you don't want a toolbar, it is simpler to add the figure directly and not worry. However, the figure manager looks after clipping of the figure contents, so you will need it if you want to navigate 3) There is a bug in the way in which my copy of wxPython calculates toolbar width on Win32, so there is a tricky line to ensure that the width of the toolbat is the same as the width of the figure. 4) Depending on the parameters you pass to the sizer, you can make the figure resizable or not. """ import matplotlib matplotlib.use('WX') from matplotlib.backends.backend_wx import Toolbar, FigureCanvasWx,\ FigureManager from matplotlib.figure import Figure from matplotlib.axes import Subplot import numpy #from wx import * import wx class PlotFigure(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, -1, "Test embedded wxFigure") self.fig = Figure((9,8), 75) self.canvas = FigureCanvasWx(self, -1, self.fig) self.toolbar = Toolbar(self.canvas) self.toolbar.Realize() # On Windows, default frame size behaviour is incorrect # you don't need this under Linux tw, th = self.toolbar.GetSizeTuple() fw, fh = self.canvas.GetSizeTuple() self.toolbar.SetSize(wx.Size(fw, th)) # Create a figure manager to manage things self.figmgr = FigureManager(self.canvas, 1, self) # Now put all into a sizer sizer = wx.BoxSizer(wx.VERTICAL) # This way of adding to sizer allows resizing sizer.Add(self.canvas, 1, wx.LEFT|wx.TOP|wx.GROW) # Best to allow the toolbar to resize! sizer.Add(self.toolbar, 0, wx.GROW) self.SetSizer(sizer) self.Fit() def plot_data(self): # Use ths line if using a toolbar a = self.fig.add_subplot(111) # Or this one if there is no toolbar #a = Subplot(self.fig, 111) t = numpy.arange(0.0,3.0,0.01) s = numpy.sin(2*numpy.pi*t) c = numpy.cos(2*numpy.pi*t) a.plot(t,s) a.plot(t,c) self.toolbar.update() def GetToolBar(self): # You will need to override GetToolBar if you are using an # unmanaged toolbar in your frame return self.toolbar if __name__ == '__main__': app = wx.PySimpleApp(0) frame = PlotFigure() frame.plot_data() frame.Show() app.MainLoop() - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. 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] plotting a pcolormesh and a fill
I have a pcolormest and a fill that are plotted on the same graph (they have the same scale). Is there an easy way to only plot the values of pcolormesh that lie in the fill? pcolormesh(oX, oY, test, shading='flat', cmap=cm.gray_r) fill([-x1,x2,x2,-x1], [-y1,-y1,y2,y2], 'b', alpha=0.2, edgecolor='r') -- "The game of science can accurately be described as a never-ending insult to human intelligence." - João Magueijo - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. 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] RuntimeError after clearing and plotting for many times
+1 Worked for me too. Thanks. ~ musically_ut On Dec 12, 2007 7:45 PM, Armando Serrano Lombillo <[EMAIL PROTECTED]> wrote: > Ok, I've just read the thread "Repeated calls to set_text using TeX > formatting results in RuntimeError" which looked very similar to our problem > and after applying the fix which is suggested there by Michael Droettboom > (see below), the problem seems to disappear. Let's hope this gets fixed in > 0.91.2. > > > Open the file "font_manager.py", which should live in > "%PYTHONPATH%/Lib/site-packages/matplotlib". Around line 681, you'll > find the function: > > def __hash__(self): > return hash(repr(self.__props)) > > Change it to: > > def __hash__(self): > return hash(repr(self.__props.__dict__)) > > (Obviously, back up the file first...) > > > On Dec 12, 2007 8:32 PM, Armando Serrano Lombillo <[EMAIL PROTECTED]> > wrote: > > > I'm running into the very same problem. I'm using matplotlib from a > > wxPython application, the same versions as you (Yongtao Cui), and I get the > > same error (see below) after repainting a figure many times. In my case I > > plot several figures (16 figures) and I get the error with very few > > repaintings. This didn't happen with matplotlib 0.90.1. > > > > Any fix besides going back to matplotlib 0.90.1? > > > > > > Traceback (most recent call last): > > Traceback (most recent call last): > > File "C:\Tesis\Programa\visualizador.py", line 93, in on_intervalos > > File "C:\Tesis\Programa\visualizador.py", line 126, in pinta > > File > > "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wxagg.py", line > > 61, in draw > > File > > "C:\Python25\Lib\site-packages\matplotlib\backends\backend_agg.py", line > > 380, in draw > > File "C:\Python25\Lib\site-packages\matplotlib\figure.py", line 612, > > in draw > > File "C:\Python25\Lib\site-packages\matplotlib\axes.py", line 1344, in > > draw > > File "C:\Python25\Lib\site-packages\matplotlib\axis.py", line 596, in > > draw > > File "C:\Python25\Lib\site-packages\matplotlib\axis.py", line 170, in > > draw > > File "C:\Python25\Lib\site-packages\matplotlib\text.py", line 775, in > > draw > > File "C:\Python25\Lib\site-packages\matplotlib\text.py", line 317, in > > draw > > File "C:\Python25\Lib\site-packages\matplotlib\text.py", line 195, in > > _get_layout > > File > > "C:\Python25\Lib\site-packages\matplotlib\backends\backend_agg.py", line > > 234, in get_text_width_height_descent > > File > > "C:\Python25\Lib\site-packages\matplotlib\backends\backend_agg.py", line > > 301, in _get_agg_font > > RuntimeError: Could not open facefile C:\WINDOWS\Fonts\verdana.ttf; > > Cannot_Open_Resource > > > > File "C:\Tesis\Programa\visualizador.py", line 93, in on_intervalos > > File "C:\Tesis\Programa\visualizador.py", line 126, in pinta > > File > > "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wxagg.py", line > > 61, in draw > > File > > "C:\Python25\Lib\site-packages\matplotlib\backends\backend_agg.py", line > > 380, in draw > > File "C:\Python25\Lib\site-packages\matplotlib\figure.py", line 612, > > in draw > > File "C:\Python25\Lib\site-packages\matplotlib\axes.py", line 1344, in > > draw > > File "C:\Python25\Lib\site-packages\matplotlib\axis.py", line 596, in > > draw > > File "C:\Python25\Lib\site-packages\matplotlib\axis.py", line 170, in > > draw > > File "C:\Python25\Lib\site-packages\matplotlib\text.py", line 775, in > > draw > > File "C:\Python25\Lib\site-packages\matplotlib\text.py", line 317, in > > draw > > File "C:\Python25\Lib\site-packages\matplotlib\text.py", line 195, in > > _get_layout > > File > > "C:\Python25\Lib\site-packages\matplotlib\backends\backend_agg.py", line > > 234, in get_text_width_height_descent > > File > > "C:\Python25\Lib\site-packages\matplotlib\backends\backend_agg.py", line > > 301, in _get_agg_font > > RuntimeError: Could not open facefile C:\WINDOWS\Fonts\verdana.ttf; > > Cannot_Open_Resource > > > > > > > > > > On Dec 5, 2007 3:15 AM, Yongtao Cui <[EMAIL PROTECTED]> wrote: > > > > > I don't know why those spaces always don't show up on the mailing list > > > webpage. They looked fine on my gmail page. > > > > > > The 'test' function only has one 'for' loop. The four lines below the > > > 'for' line are all in the loop. > > > > > > > > > > > > On Dec 4, 2007 8:52 PM, Yongtao Cui <[EMAIL PROTECTED]> wrote: > > > > >>> import pylab > > > > >>> def test(n): > > > > >>> for i in range(n): > > > > >>> f=pylab.figure(1) > > > > >>> f.clf() > > > > >>> a=f.add_axes([0.2, 0.2, 0.6 , 0.6]) > > > > >>> a.plot([1,2,3,4,5], 'ro') > > > > >>> > > > > > > > > I tracked down the svn tree. The above script works ok in revision > > > > 3737 and before, but crashes from revision 3738 and after. > > > > > > > > Yongtao > > > > > > > > > > > > On Dec 2, 2007 4:15 PM, Yongtao Cui <[EMAIL PROTECTED]> wrote: > > > > > Below is the minimum code with the right in
[Matplotlib-users] (no subject)
Hi guys and girls, Quick question regarding matplotlib's svg backend... I've embeded pyhton into c++ and Qt's (4.3.3) svg support is having some problems with .svg files created by matplotlib. Text isn't showing up. Firefox displays the same .svg file correctly though... The problem: It seems some text stuff is stored in a section called defs at the end of the file with stuff linking to this earlier in the file. Qt doesn't like that and only displays the normal plot stuff (lines, etc.) but not the labels and other text. More exact: 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] axes numbers font size
Hello, I just started looking into python and matplotlib a few days ago and I am amazed that this software can do more or less the same as MATLAB. I just have a couple of questions regarding some stuff that I spent a lot of time without figuring out. 1. Is there a way to change the font type and font size of the numbers on the axes in a figure? Not the labels (xlabel and ylabel - they are easy to change), but the actual numbers. If for example x goes from 0 to 6 in step of 2, the numbers showing below the x axis would be 0, 2, 4, and 6 for example. It is the fontsize and font of these numbers that I want to change. It must be some axis property but I cannot figure it out. 2. I will be using the figures plotted in matplotlib mainly to import them in LATEX documents. Since Latex uses Computer modern font by default, is there a way to change the default font in matplotlib to match it? What would be the actual command? 3. The data that I would like to plot is in an ASCII format, where the first row and column is text and the rest is numbers. What would be the best way to import that into maplotlib and then assign a variable name to each column (without the first entry, which would be the variable name). Thanks a lot in advance. _ Сдобий се със следващата генерация Windows Live услуги сега! http://get.live.com - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. 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] pylab axis query and possible bug
On Dec 21, 2007 11:50 AM, John Hunter <[EMAIL PROTECTED]> wrote: > On Dec 20, 2007 9:22 PM, Gary Ruben <[EMAIL PROTECTED]> wrote: > > Hi listees, > > > > I often generate plots using the pylab interface plot() function to > > overlay an imshow() image. The minimal script below demonstrates a > > problem, which may be a bug, or may be a deliberate change introduced > > into mpl 0.91.1. It works fine with mpl 0.90.1 but gives a traceback > > with 0.91.1 - it seems not to be happy with the subplot limits. > > Commenting out the "note 1" line lets it run and demonstrates my real > > question. With scatter(), the first subplot doesn't rescale, but if line > > "note 2" is commented out and "note 3" is uncommented, it rescales. How > > do I prevent the rescaling? I prefer plot() instead of scatter() in this > > case because of the plot origin. You can manually turn off autoscaling on the axes instance with the following, and both scatter and plot should then work as you want. ax1 = subplot(121) axis('off') ax1.imshow(rand(20,20)) ax2 = subplot(122) axis('off') ax2.imshow(rand(20,20)) ax1.set_autoscale_on(False) #ax1.scatter([5,10],[5,10])# note 2 ax1.plot([5,10],[5,10], 'o') # note 3 show() > > > > Hey Gary, thanks for the resend. > > On your first question vis-a-vis subplots_adjust, it looks like the > validate limits are wrong for these params. I'm CC-ing Darren because > he has done the most work recently for rc param validation. > > They currently read: > > 'figure.subplot.left' : [0.125, ValidateInterval(0, 1, > closedmin=False, closedmax=False)], > 'figure.subplot.right' : [0.9, ValidateInterval(0, 1, > closedmin=False, closedmax=False)], > 'figure.subplot.bottom' : [0.1, ValidateInterval(0, 1, > closedmin=False, closedmax=False)], > 'figure.subplot.top': [0.9, ValidateInterval(0, 1, > closedmin=False, closedmax=False)], > 'figure.subplot.wspace' : [0.2, ValidateInterval(0, 1, > closedmin=False, closedmax=True)], > 'figure.subplot.hspace' : [0.2, ValidateInterval(0, 1, > closedmin=False, closedmax=True)], > > and I think they should read: > > > 'figure.subplot.left' : [0.125, ValidateInterval(0, 1, > closedmin=True, closedmax=True)], > 'figure.subplot.right' : [0.9, ValidateInterval(0, 1, > closedmin=True, closedmax=True)], > 'figure.subplot.bottom' : [0.1, ValidateInterval(0, 1, > closedmin=True, closedmax=True)], > 'figure.subplot.top': [0.9, ValidateInterval(0, 1, > closedmin=True, closedmax=True)], > 'figure.subplot.wspace' : [0.2, ValidateInterval(0, 1, > closedmin=True, closedmax=False)], > 'figure.subplot.hspace' : [0.2, ValidateInterval(0, 1, > closedmin=True, closedmax=False)], > > That is, 0 and 1 should be legal for all values except the max of the > wspace and hspace. Darren, unless I am missing something, I'll commit > these changes. > > I'll look at your second question in a followup > > JDH > - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. 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] pylab axis query and possible bug
On Dec 20, 2007 9:22 PM, Gary Ruben <[EMAIL PROTECTED]> wrote: > Hi listees, > > I often generate plots using the pylab interface plot() function to > overlay an imshow() image. The minimal script below demonstrates a > problem, which may be a bug, or may be a deliberate change introduced > into mpl 0.91.1. It works fine with mpl 0.90.1 but gives a traceback > with 0.91.1 - it seems not to be happy with the subplot limits. > Commenting out the "note 1" line lets it run and demonstrates my real > question. With scatter(), the first subplot doesn't rescale, but if line > "note 2" is commented out and "note 3" is uncommented, it rescales. How > do I prevent the rescaling? I prefer plot() instead of scatter() in this > case because of the plot origin. > Hey Gary, thanks for the resend. On your first question vis-a-vis subplots_adjust, it looks like the validate limits are wrong for these params. I'm CC-ing Darren because he has done the most work recently for rc param validation. They currently read: 'figure.subplot.left' : [0.125, ValidateInterval(0, 1, closedmin=False, closedmax=False)], 'figure.subplot.right' : [0.9, ValidateInterval(0, 1, closedmin=False, closedmax=False)], 'figure.subplot.bottom' : [0.1, ValidateInterval(0, 1, closedmin=False, closedmax=False)], 'figure.subplot.top': [0.9, ValidateInterval(0, 1, closedmin=False, closedmax=False)], 'figure.subplot.wspace' : [0.2, ValidateInterval(0, 1, closedmin=False, closedmax=True)], 'figure.subplot.hspace' : [0.2, ValidateInterval(0, 1, closedmin=False, closedmax=True)], and I think they should read: 'figure.subplot.left' : [0.125, ValidateInterval(0, 1, closedmin=True, closedmax=True)], 'figure.subplot.right' : [0.9, ValidateInterval(0, 1, closedmin=True, closedmax=True)], 'figure.subplot.bottom' : [0.1, ValidateInterval(0, 1, closedmin=True, closedmax=True)], 'figure.subplot.top': [0.9, ValidateInterval(0, 1, closedmin=True, closedmax=True)], 'figure.subplot.wspace' : [0.2, ValidateInterval(0, 1, closedmin=True, closedmax=False)], 'figure.subplot.hspace' : [0.2, ValidateInterval(0, 1, closedmin=True, closedmax=False)], That is, 0 and 1 should be legal for all values except the max of the wspace and hspace. Darren, unless I am missing something, I'll commit these changes. I'll look at your second question in a followup JDH - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. 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