Re: [Matplotlib-users] colorbar tick labeling
2008/11/21 Eric Firing <[EMAIL PROTECTED]>: > Michael Outhouse wrote: >> I was wondering if it is possible to change the colorbar tick labeling in >> matplotlib from numeric to text. Essentially, I want the colorbar to be a >> qualitative indicator; in the jet scheme, I'd like blue to be labeled >> as 'unstable', green as 'neutral', and red as 'stable'. I can change it so I >> just show the underlying values - colorbar(ticks = (-1, 0, 1)), but I cannot >> change the the tick labels to text. Is there any way to accomplish this? >> Thanks in advance for any help. > > Your message came more than a month ago, but it looks like no one > answered, so here is an answer: > > with ipython -pylab: > > imshow(2*rand(10,10) - 1, vmin=-1, vmax=1) > cbar = colorbar(ticks=[-1,0,1]) > cbar.ax.set_yticklabels(['unstable', 'neutral', 'stable']) > draw() Also see the example here http://matplotlib.sourceforge.net/examples/pylab_examples/colorbar_tick_labelling_demo.html. Cheers, Scott - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] poly_between and time series data
Shailesh Kochhar wrote: > Hello, > > I am trying to fill the space below a curve where my x-axis is indexed > by time. The matplotlib api documentation and the examples don't touch > on this subject and I haven't had much luck trying a few different > variations. Here's what I've tried so far, maybe someone can point out > what I'm doing wrong. > > import time > import matplotlib.pyplot as plt > import matplotlib.mlab as mlab > > time_strings = [ list of times as strings ] > xs = [ date2num(time.strptime(string) for string in time_strings ] > ys = [ list of float values ] > > fig = plt.figure() > ax = fig.add_subplot(111) > ax.plot_date(xs, ys) > > xv, yv = mlab.poly_below(0, xs, ys) > ax.fill(xv, yv) > > > When I do this, I get a 'year out of range' error. If I try and fill the > area before the call to ax.plot_date, The fill looks like a solid bar > about the height of the max y-value. What is the actual traceback? Please provide a simple but complete example that shows the problem--that is, flesh out your pseudocode above into a small standalone script that triggers the error. Eric > > From, looking at the posts on the mailing list it doesn't seem that I'm > doing something terribly wrong, maybe I'm missing something subtle? > > Thanks, >- Shailesh > > - > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] poly_between and time series data
Hello, I am trying to fill the space below a curve where my x-axis is indexed by time. The matplotlib api documentation and the examples don't touch on this subject and I haven't had much luck trying a few different variations. Here's what I've tried so far, maybe someone can point out what I'm doing wrong. import time import matplotlib.pyplot as plt import matplotlib.mlab as mlab time_strings = [ list of times as strings ] xs = [ date2num(time.strptime(string) for string in time_strings ] ys = [ list of float values ] fig = plt.figure() ax = fig.add_subplot(111) ax.plot_date(xs, ys) xv, yv = mlab.poly_below(0, xs, ys) ax.fill(xv, yv) When I do this, I get a 'year out of range' error. If I try and fill the area before the call to ax.plot_date, The fill looks like a solid bar about the height of the max y-value. From, looking at the posts on the mailing list it doesn't seem that I'm doing something terribly wrong, maybe I'm missing something subtle? Thanks, - Shailesh - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] A wxPython/Matplotlib/Basemap example
Mauro Cavalcanti wrote: > Dear Chris, > > Thank your very much for your prompt reply. > > 2008/11/20 Christopher Barker <[EMAIL PROTECTED]>: > > >> well, I love sizers -- but they do take a while to wrap your brain around. >> > > I love Python *and* wxPython/wxWidgets -- but having worked several > years with RAD tools like Visual Basic and (much better) Borland > Delphi, I find all available GUI builders for Python very limited (and > sizers are among these perceived limitations). > > I agree (coming from Delphi), they either don't work or are too limited. For wxPython I developed a very simple method, which even has the F12 function ;-) http://mientki.ruhosting.nl/data_www/pylab_works/pw_gui_support.htm code can be downloaded here http://code.google.com/p/pylab-works/downloads/list btw I would love to see your Basemap, (but as I'm in the iddle of releasing a large project based on an old version of MatPlatLib, so I don't dare to update), are there any screenshots ? thanks, Stef Mientki - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] A wxPython/Matplotlib/Basemap example
Dear Chris, Thank your very much for your prompt reply. 2008/11/20 Christopher Barker <[EMAIL PROTECTED]>: > well, I love sizers -- but they do take a while to wrap your brain around. I love Python *and* wxPython/wxWidgets -- but having worked several years with RAD tools like Visual Basic and (much better) Borland Delphi, I find all available GUI builders for Python very limited (and sizers are among these perceived limitations). > Your difficulty probably stems from using a combination of wxGlade and > handwritten code. Also, I don't know if wxGlade forces you to do it this As a matter of fact, wxGlade forces one to do this. I usually do not like (or use) code generated by wxGlade, but for rapid prototyping I find it to be better than, for example, Boa Constructor (which is as huge and slow is the boa snakes themselves). > you've given "self" as the parent of your FigureCanvas, when it needs to be > parented by the Panel it goes on, which I think is self.PlotPanel, so the > above line should be: Sure, it worked, but I still have problems with properly sizing the figure. This I could amend by declaring: self.figure = Figure() instead of self.figure = Figure(figsize=(10,5)) and: self.ax = self.figure.add_subplot(111) instead of self.ax = self.figure.add_axes([0,0,1,1]) However the figure is still not properly sized when the window is maximized (but this is obviously another problem with my handling of wxPython classes). I hope to have this example up and running as it may be a useful addition to the collection of examples in the Basemap module, saving a lot of time for others! With best regards, -- Dr. Mauro J. Cavalcanti Ecoinformatics Studio P.O. Box 46521, CEP 20551-970 Rio de Janeiro, RJ, BRASIL E-mail: [EMAIL PROTECTED] Web: http://studio.infobio.net Linux Registered User #473524 * Ubuntu User #22717 "Life is complex. It consists of real and imaginary parts." - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] small bug in slider_demo.py
Matthias Michler wrote: > Hello list, > > I observe a small bug in slider_demo.py, which lives in the svn > folder /examples/widgets and can be accessed via > http://matplotlib.sourceforge.net/_static/plot_directive/mpl_examples/widgets/slider_demo.py > . > > The hovercolor for grey needs to be a string instead of a float. I attached a > small patch for simplicity. Thank you, I applied it. Eric - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] colorbar tick labeling
Michael Outhouse wrote: > I was wondering if it is possible to change the colorbar tick labeling in > matplotlib from numeric to text. Essentially, I want the colorbar to be a > qualitative indicator; in the jet scheme, I'd like blue to be labeled > as 'unstable', green as 'neutral', and red as 'stable'. I can change it so I > just show the underlying values - colorbar(ticks = (-1, 0, 1)), but I cannot > change the the tick labels to text. Is there any way to accomplish this? > Thanks in advance for any help. Your message came more than a month ago, but it looks like no one answered, so here is an answer: with ipython -pylab: imshow(2*rand(10,10) - 1, vmin=-1, vmax=1) cbar = colorbar(ticks=[-1,0,1]) cbar.ax.set_yticklabels(['unstable', 'neutral', 'stable']) draw() - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] A wxPython/Matplotlib/Basemap example
Mauro Cavalcanti wrote: > Well, at least it should! It turns out that the map is correctly > displayed, but it then fills almost the whole parent window, > overlapping the left panel where the notebook with the listbox and the > text control should appear! This illustrates one of the worst (in my > opinion) things about wxPython, that is the handling of "sizers" to > correctly place the widgets on an application window. well, I love sizers -- but they do take a while to wrap your brain around. Your difficulty probably stems from using a combination of wxGlade and handwritten code. Also, I don't know if wxGlade forces you to do it this way, but you have a whole bunch of stuff all nested in the Frame, when it would be better designed if each component was it's own class. anyway, I think your problem is: # - UNCOMMENT THE LINES BELOW TO DRAW THE MAP #self.figure = Figure(figsize=(10,5)) #self.canvas = FigureCanvas(self, -1, self.figure) you've given "self" as the parent of your FigureCanvas, when it needs to be parented by the Panel it goes on, which I think is self.PlotPanel, so the above line should be: self.canvas = FigureCanvas(self.PlotPanel, -1, self.figure) One thing wx does do "wrong" is let you put a control on one parent, then Add it to a sizer attached to a different parent -- it should probably raise an error when you do that. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] wx backup show figure (WAS: general matplotlib usage questions)
On Thu, Nov 20, 2008 at 8:14 PM, John Hunter <[EMAIL PROTECTED]> wrote: > > One more thought -- if you are in pylab mode (so "interactive" is > turned on) if you are making your draw calls through the api, as you > are in this example, you will need to call draw after the plot > commands, eg > > ax.plot(something) > f.canvas.draw() Right, that's it - with wx I need to use canvas.draw... I was aware of the need to use something, but with Tk was previously using figure.show (possibly incorrectly having read the documentation)- which doesn't have any effect in the wx case. Thanks very much to everyone for the prompt responses today! Cheer Robin - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Qestion on Matplotlib GUI backends toolbars
Dear ALL, Just a simple (?) question on Matplotlib GUI backends toolbars. The Matplotlib examples include a nice sample of programmatically adding a button to a backend toolbar, but I could not find out how to *remove* one or more of the buttons from the default toolbar. Has it be sub-classed? BTW, is there any way to access (from a program) the methods bound to each toolbar button? Thanks again for your attention (and patience, of course!) With best regards, -- Dr. Mauro J. Cavalcanti Ecoinformatics Studio P.O. Box 46521, CEP 20551-970 Rio de Janeiro, RJ, BRASIL E-mail: [EMAIL PROTECTED] Web: http://studio.infobio.net Linux Registered User #473524 * Ubuntu User #22717 "Life is complex. It consists of real and imaginary parts." - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plotting labels for each 'artist' in a basemap
I just saw a similar error when trying to plot some text; in my case, basemap wasn't involved. The full error dump: /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/text.py in draw(self, renderer) 486 --> 487 for line, wh, x, y in info: 488 x = x + posx 489 y = y + posy TypeError: CXX : Error creating object of type N2Py3IntE My x data were times in seconds calculated relative to a reference date, and reducing the gap cleared up my problem. This thread: http://markmail.org/message/zqfgrshmq3366mtz?q=Error+N2Py3IntE suggests that the error is due to an overflow in the underlying numerics. And ... this is where I reach the end of my expertise. -Eric On Thu, Nov 13, 2008 at 11:38 PM, John [H2O] <[EMAIL PROTECTED]> wrote: > > Hello, using matplotlib 0.98 with mpl_toolkit Basemap: > > I'm trying to create a plot with a series of ellipses over a map. I've > followed the tutorial, and can create the same figure as shown here: > http://matplotlib.sourceforge.net/users/screenshots.html#ellipses > > I can also create a series of ellipses over a map. > > Now I am trying to label each circle using the following snippet: > for item in ells: >#ells is now a tuple in the form: (Ellipse, (x,y)) and (x,y) is the same > as for the Ellipse > e = item[0] > xy = item[1] > ax.add_artist(e) > e.set_clip_box(ax.bbox) > e.set_alpha(.7) > pyplot.text(xy[0],xy[1],e.get_label()) > > however, for some reason it fails. Can someone provide some ideas on what I > am doing wrong? Also, is there more direct way to set the plots so that the > labels are drawn? > > What is strange, is that it seems to work (at least debugging print > statements after the loop are printed)... and I can move the text function > out of the loop to label the 'last' ellipse... > > As it is it fails when savefig() or show() are called. The error is: > TypeError: CXX : Error creating object of type N2Py3IntE > > THoughts? > > Thanks, > john > > -- > View this message in context: > http://www.nabble.com/plotting-labels-for-each-%27artist%27-in-a-basemap-tp20494609p20494609.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > > > - > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] A wxPython/Matplotlib/Basemap example
Dear ALL, Enclosed is an sample application I put together (partially using wxGlade) that is a first attempt at providing a working example of a GUI frontend with wxPython and Matplotlib/Basemap. The application consists of two panels, separated by a splitter. The left panel has a notebook with two pages, which have, respectively, a listbox and a read-only multine text control. The right panel has a figure object created at runtime, to which a basemap object is attached. The application reads comma-delimited data files of geographic coordinates (in decimal format) selected by the user, appending them to the listbox. When a file is selected on the list, the points are plotted on the basemap displayed in the panel to the right. Well, at least it should! It turns out that the map is correctly displayed, but it then fills almost the whole parent window, overlapping the left panel where the notebook with the listbox and the text control should appear! This illustrates one of the worst (in my opinion) things about wxPython, that is the handling of "sizers" to correctly place the widgets on an application window. I have commented the parts of the code where the map is created, so that one can see clearly what happens with and without the map plot. Just uncomment these parts to see the map displayed (with a toolbar properly placed, at least under Linux). If someone can help me with this, this sample application could provide a useful skeleton to build programs which integrate Matplotlib/Basemap with wxPython (incidentally, this sample application bears a very slight resemblance to Google Earth... :)). I am, of course, donating it to the community. Thanks in advance! With best regards, -- Dr. Mauro J. Cavalcanti Ecoinformatics Studio P.O. Box 46521, CEP 20551-970 Rio de Janeiro, RJ, BRASIL E-mail: [EMAIL PROTECTED] Web: http://studio.infobio.net Linux Registered User #473524 * Ubuntu User #22717 "Life is complex. It consists of real and imaginary parts." #!/usr/bin/env python # -*- coding: utf-8 -*- # generated by wxGlade 0.6.3 on Thu Nov 20 17:06:15 2008 # This sample program shows how to read # geographic coordinates stored in comma-delimited files # and plot them in a Matplotlib Basemap class object. # Data files should be formatted as below: # cities,latitude,longitude # "Boulder, CO",40.02,-105.16 # "San Diego, CA",32.73,-117.16 # "Washington, DC",38.55,-77.00 # "Whitefish, MT",48.25,-114.21 # "Belize City, Belize",17.29,-88.10 import os import csv import wx from matplotlib.backends.backend_wx import FigureCanvasWx as FigureCanvas from matplotlib.backends.backend_wx import NavigationToolbar2Wx from matplotlib.figure import Figure from mpl_toolkits.basemap import Basemap fields = {'cities':0, 'latitude':1, 'longitude':2} # begin wxGlade: extracode # end wxGlade class TMainForm(wx.Frame): def __init__(self, *args, **kwds): # begin wxGlade: TMainForm.__init__ kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.Splitter = wx.SplitterWindow(self, -1, style=wx.SP_3D|wx.SP_BORDER) self.PlotPanel = wx.Panel(self.Splitter, -1) self.FilePanel = wx.Panel(self.Splitter, -1) self.Notebook = wx.Notebook(self.FilePanel, -1, style=0) self.ReportPage = wx.Panel(self.Notebook, -1) self.FilePage = wx.Panel(self.Notebook, -1) # Menu Bar self.MainMenu = wx.MenuBar() self.FileMenu = wx.Menu() self.FileOpenItem = wx.MenuItem(self.FileMenu, 102, "&Open...\tCtrl+O", "Open an existing file", wx.ITEM_NORMAL) self.FileMenu.AppendItem(self.FileOpenItem) self.FileMenu.AppendSeparator() self.FileQuitItem = wx.MenuItem(self.FileMenu, wx.ID_EXIT, "&Quit\tCtrl+Q", "Quit the program", wx.ITEM_NORMAL) self.FileMenu.AppendItem(self.FileQuitItem) self.MainMenu.Append(self.FileMenu, "&File") self.HelpMenu = wx.Menu() self.HelpAboutItem = wx.MenuItem(self.HelpMenu, 201, "&About...", "Display general information about the program", wx.ITEM_NORMAL) self.HelpMenu.AppendItem(self.HelpAboutItem) self.MainMenu.Append(self.HelpMenu, "&Help") self.SetMenuBar(self.MainMenu) # Menu Bar end self.StatusBar = self.CreateStatusBar(2, wx.ST_SIZEGRIP) self.FileList = wx.ListBox(self.FilePage, -1, choices=[]) self.ReportText = wx.TextCtrl(self.ReportPage, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY) self.__set_properties() self.__do_layout() self.Bind(wx.EVT_MENU, self.OnFileOpen, self.FileOpenItem) self.Bind(wx.EVT_MENU, self.OnFileQuit, self.FileQuitItem) self.Bind(wx.EVT_MENU, self.OnHelpAbout, self.HelpAboutItem) self.Bind(wx.EVT_LISTBOX, self.OnSelect, self.FileList) # end wxGlade def __set_properties(self): # begin wxGlade: TMainForm.__set_properties self.SetTitle("Gaia") self.SetSize((800, 600)) self.SetFocus() self.StatusBar.SetStatusWidths([-1, -1]) # statusbar fields StatusBar_fields = ["Ready", ""] for i in range(len(StatusBar_fields)): self.StatusBar.SetStatusText(StatusBar_fields[i], i) self.FileList.Se
Re: [Matplotlib-users] wx backup show figure (WAS: general matplotlib usage questions)
On Thu, Nov 20, 2008 at 1:29 PM, Robin <[EMAIL PROTECTED]> wrote: > On Thu, Nov 20, 2008 at 5:22 PM, Christopher Barker >> try wxPython -- it's easy to install and works well. > > Thanks - it does seem nicer (doesn't have the mouse over resizing)... > > However I have one problem where a figure I create in a function > doesn't show up: > # this is how I create a figure in a function > In [20]: def test_func(): > : f = figure() > : ax = f.add_subplot(111) > : ax.plot([1,2,3,4],[1,2,3,4]) > : f.show() > : return f > : One more thought -- if you are in pylab mode (so "interactive" is turned on) if you are making your draw calls through the api, as you are in this example, you will need to call draw after the plot commands, eg ax.plot(something) f.canvas.draw() This is explained in some detail in the shell page I pointed you to in my last post. JDH - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] wx backup show figure (WAS: general matplotlib usage questions)
On Thu, Nov 20, 2008 at 1:29 PM, Robin <[EMAIL PROTECTED]> wrote: > On Thu, Nov 20, 2008 at 5:22 PM, Christopher Barker >> try wxPython -- it's easy to install and works well. > > Thanks - it does seem nicer (doesn't have the mouse over resizing)... > > However I have one problem where a figure I create in a function > doesn't show up: > # this is how I create a figure in a function Are you running ipython in pylab mode? See http://matplotlib.sourceforge.net/users/shell.html and http://matplotlib.sourceforge.net/faq/howto_faq.html#use-show - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] memory leak
Hi, I have noticed a memory leak when using pylab.pcolor. Here is the code, fa() and fb() do the same thing. The difference is the size of the array which is passed to pcolor. With a large array pcolor leaks but not with a small one. Cheers, Ben import numpy as np import matplotlib matplotlib.use('Agg') from matplotlib import pylab def fa(): """ This function leaks. """ a = np.arange(1024**2) a = a.reshape(1024,1024) for i in range(1): pylab.pcolor(a) pylab.close() def fb(): """This function does not leak. """ b = np.arange(1024) b = b.reshape(32,32) for i in range(1024): pylab.pcolor(b) pylab.close() - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] wx backup show figure (WAS: general matplotlib usage questions)
On Thu, Nov 20, 2008 at 5:22 PM, Christopher Barker > try wxPython -- it's easy to install and works well. Thanks - it does seem nicer (doesn't have the mouse over resizing)... However I have one problem where a figure I create in a function doesn't show up: # this is how I create a figure in a function In [20]: def test_func(): : f = figure() : ax = f.add_subplot(111) : ax.plot([1,2,3,4],[1,2,3,4]) : f.show() : return f : In [21]: test_func() Out[21]: # shows a blank (grey) canvas with no axes In [23]: _21.show() # ^^ does nothing In [25]: gcf().show() # ^^ does nothing In [26]: f2 = figure(1) # ^^ now it appears? So what am I doing wrong? How can I programmatically display a figure (ie without knowing the number in advance to do figure(n)?) Cheers Robin - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Save a plot background
Hrafnkell Pálsson wrote: > Jeff Whitaker wrote: > >> Hrafnkell: >> >> Had some time this morning, so I used John's method to create a working >> Basemap example: >> >> import matplotlib >> matplotlib.use('Agg') >> from mpl_toolkits.basemap import Basemap >> import matplotlib.pyplot as plt >> >> # this example shows how to save a map background and >> # reuse it in another figure. >> >> # make sure we have all the same properties on all figs >> figprops = dict(figsize=(8,6), dpi=100, facecolor='white') >> >> # generate the first figure. >> fig1 = plt.figure(1,**figprops) >> ax1 = fig1.add_subplot(111) >> # create basemap instance, plot coastlines. >> map = Basemap(projection='moll',lon_0=0) >> map.drawcoastlines() >> map.drawmapboundary(fill_color='aqua') >> map.fillcontinents(color='coral',lake_color='aqua') >> fig1.canvas.draw() >> background = fig1.canvas.copy_from_bbox(fig1.bbox) >> fig1.savefig('figure1.png', dpi=100) >> >> >> # generate the second figure, re-using the background >> # from figure 1. >> fig2 = plt.figure(2,frameon=False,**figprops) >> ax2 = fig2.add_subplot(111, frameon=False, xticks=[], yticks=[]) >> # restore previous background. >> fig2.canvas.restore_region(background) >> # draw parallels and meridians on existing background. >> map.drawparallels(range(-90,90,30)) >> map.drawmeridians(range(-180,180,60)) >> fig2.savefig('figure2.png', dpi=100) >> >> >> I've added this to the basemap examples directory as save_background.py >> >> HTH, >> >> -Jeff >> >> > > There's still one snag. > Using your example I could restore the background. > But it turns out everything is plotted over the background; so if my > background consist only of the coastline and then I do a filled contour plot > after restoring it the coastline disappears under the filled contours (by > using the alpha keyword to contourf I could see the coastline beneath). > > Had I plotted the coastline into the figure instead of restoring it this > would not have happened. > > Is there any way of avoiding this? > > Hrafnkell > > > > Hrafnkell: I see your point, but I don't see any obvious solution. Perhaps someone with more knowledge of matplotlib internals (John?) can answer. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX: (303)497-6449 NOAA/OAR/PSD R/PSD1Email : [EMAIL PROTECTED] 325 BroadwayOffice : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Save a plot background
Jeff Whitaker wrote: > > Hrafnkell: > > Had some time this morning, so I used John's method to create a working > Basemap example: > > import matplotlib > matplotlib.use('Agg') > from mpl_toolkits.basemap import Basemap > import matplotlib.pyplot as plt > > # this example shows how to save a map background and > # reuse it in another figure. > > # make sure we have all the same properties on all figs > figprops = dict(figsize=(8,6), dpi=100, facecolor='white') > > # generate the first figure. > fig1 = plt.figure(1,**figprops) > ax1 = fig1.add_subplot(111) > # create basemap instance, plot coastlines. > map = Basemap(projection='moll',lon_0=0) > map.drawcoastlines() > map.drawmapboundary(fill_color='aqua') > map.fillcontinents(color='coral',lake_color='aqua') > fig1.canvas.draw() > background = fig1.canvas.copy_from_bbox(fig1.bbox) > fig1.savefig('figure1.png', dpi=100) > > > # generate the second figure, re-using the background > # from figure 1. > fig2 = plt.figure(2,frameon=False,**figprops) > ax2 = fig2.add_subplot(111, frameon=False, xticks=[], yticks=[]) > # restore previous background. > fig2.canvas.restore_region(background) > # draw parallels and meridians on existing background. > map.drawparallels(range(-90,90,30)) > map.drawmeridians(range(-180,180,60)) > fig2.savefig('figure2.png', dpi=100) > > > I've added this to the basemap examples directory as save_background.py > > HTH, > > -Jeff > There's still one snag. Using your example I could restore the background. But it turns out everything is plotted over the background; so if my background consist only of the coastline and then I do a filled contour plot after restoring it the coastline disappears under the filled contours (by using the alpha keyword to contourf I could see the coastline beneath). Had I plotted the coastline into the figure instead of restoring it this would not have happened. Is there any way of avoiding this? Hrafnkell -- View this message in context: http://www.nabble.com/Save-a-plot-background-tp20519596p20606641.html Sent from the matplotlib - users mailing list archive at Nabble.com. - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] cbook.is_scalar('foo') is False
Cyrille Rosset wrote: > Hello, > > It seems to me there is a bug in matplotlib 0.98.3 (or at least a > change from previous version). > > >>> matplotlib.cbook.is_scalar('foo') > False > > I would expect this to be True (otherwise, > matplotlib.cbook.flatten(['foo']) enters an infinite recursive loop). This has been fixed in svn: In [1]:import matplotlib.cbook as cb In [5]:list(cb.flatten(['foo'])) Out[5]:['foo'] See Revision 6128: http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/lib/matplotlib/cbook.py?view=log > > It used to be (0.98.0): > return is_string_like(obj) or not iterable(obj) > and now (0.98.3): > return not is_string_like(obj) and not iterable(obj) > > If it is by purpose, could someone explain it to me ? I'll then have > to change my code accordingly. > > Thanks a lot in advance, > Cyrille Rosset. > > > - > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Saving to a file in a specified directory (and creating said directory along the way)
But given the vagueness of what I asked, you're right, os.makedirs was a good suggestion too. Thanks. I think I need to sit down and spend some quality time with the os module over Thanksgiving holiday... Josh On Thu, Nov 20, 2008 at 9:30 AM, Joshua Lippai <[EMAIL PROTECTED]> wrote: > cbook.mkdirs includes a few if-then calls that only make the directory > if it doesn't already exist (in fact it actually calls os.makedirs in > the function), whereas os.makedirs raises an OSError if the folder I > specified already exists. For my purposes, the cbook implementation is > more convenient. > > Josh > > On Thu, Nov 20, 2008 at 9:22 AM, Christopher Barker > <[EMAIL PROTECTED]> wrote: >> Joshua Lippai wrote: >>> Now that just leaves creating the directory. I like >>> the cbook.mkdirs implementation a lot better than the non-recursive >>> version in os... thanks for the tip! >> >> why not os.makedirs() ? >> >> -Chris >> >> -- >> Christopher Barker, Ph.D. >> Oceanographer >> >> Emergency Response Division >> NOAA/NOS/OR&R(206) 526-6959 voice >> 7600 Sand Point Way NE (206) 526-6329 fax >> Seattle, WA 98115 (206) 526-6317 main reception >> >> [EMAIL PROTECTED] >> >> - >> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge >> Build the coolest Linux based applications with Moblin SDK & win great prizes >> Grand prize is a trip for two to an Open Source event anywhere in the world >> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >> ___ >> Matplotlib-users mailing list >> Matplotlib-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] general matplotlib usage questions
Dear Robin, I do agree (although the Python gurus here highly recommend Qt instead). wxPython is well documented and has *plenty* of exemples (much of them truly useful). I have been working hard to developing a scientific desktop application which uses wxPython for its GUI frontend and Matplotlib/Basemap for plotting maps and bar charts. Have learned a few tricks (and the help of John Hunter and Jeff Whittaker is much appreciated), which I will make available to all as soon as possible. Regards, 2008/11/20 Christopher Barker <[EMAIL PROTECTED]>: > Robin wrote: >> Now you point it out it is clear that that is what is causing it. I'm >> using python.org python on a Mac and it's not clear to me how best to >> install Qt - so at the moment Tk is the only working backend I have. > > try wxPython -- it's easy to install and works well. > > -Chris > > > > -- > Christopher Barker, Ph.D. > Oceanographer > > Emergency Response Division > NOAA/NOS/OR&R(206) 526-6959 voice > 7600 Sand Point Way NE (206) 526-6329 fax > Seattle, WA 98115 (206) 526-6317 main reception > > [EMAIL PROTECTED] > > - > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Dr. Mauro J. Cavalcanti Ecoinformatics Studio P.O. Box 46521, CEP 20551-970 Rio de Janeiro, RJ, BRASIL E-mail: [EMAIL PROTECTED] Web: http://studio.infobio.net Linux Registered User #473524 * Ubuntu User #22717 "Life is complex. It consists of real and imaginary parts." - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Saving to a file in a specified directory (and creating said directory along the way)
cbook.mkdirs includes a few if-then calls that only make the directory if it doesn't already exist (in fact it actually calls os.makedirs in the function), whereas os.makedirs raises an OSError if the folder I specified already exists. For my purposes, the cbook implementation is more convenient. Josh On Thu, Nov 20, 2008 at 9:22 AM, Christopher Barker <[EMAIL PROTECTED]> wrote: > Joshua Lippai wrote: >> Now that just leaves creating the directory. I like >> the cbook.mkdirs implementation a lot better than the non-recursive >> version in os... thanks for the tip! > > why not os.makedirs() ? > > -Chris > > -- > Christopher Barker, Ph.D. > Oceanographer > > Emergency Response Division > NOAA/NOS/OR&R(206) 526-6959 voice > 7600 Sand Point Way NE (206) 526-6329 fax > Seattle, WA 98115 (206) 526-6317 main reception > > [EMAIL PROTECTED] > > - > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Saving to a file in a specified directory (and creating said directory along the way)
On Thu, Nov 20, 2008 at 11:22 AM, Christopher Barker <[EMAIL PROTECTED]> wrote: > Joshua Lippai wrote: >> Now that just leaves creating the directory. I like >> the cbook.mkdirs implementation a lot better than the non-recursive >> version in os... thanks for the tip! > > why not os.makedirs() ? Wow, that one went right by me -- somehow missed its existence. Thanks for the pointer... JDH - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] general matplotlib usage questions
Robin wrote: > Now you point it out it is clear that that is what is causing it. I'm > using python.org python on a Mac and it's not clear to me how best to > install Qt - so at the moment Tk is the only working backend I have. try wxPython -- it's easy to install and works well. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Saving to a file in a specified directory (and creating said directory along the way)
Joshua Lippai wrote: > Now that just leaves creating the directory. I like > the cbook.mkdirs implementation a lot better than the non-recursive > version in os... thanks for the tip! why not os.makedirs() ? -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Saving to a file in a specified directory (and creating said directory along the way)
Ah, silly me. I forgot to notice I was using a path variable in the string I was giving to mlab.save. Part A works just fine when I account for that. Now that just leaves creating the directory. I like the cbook.mkdirs implementation a lot better than the non-recursive version in os... thanks for the tip! Josh On Thu, Nov 20, 2008 at 8:48 AM, John Hunter <[EMAIL PROTECTED]> wrote: > On Thu, Nov 20, 2008 at 10:24 AM, Joshua Lippai <[EMAIL PROTECTED]> wrote: >> Hey, >> >> I'm working on a project for which I would like to dump data into a >> file in a specified directory (that doesn't necessarily exist yet). I >> know matplotlib.mlab.save(fname, X) will only work if I want to save >> data from an array/list to a file in the current working directory. Is >> there an easy way using matplotlib to: >> >> A) Save a file to a specified directory rather than the current >> working directory > > Just specify the full path to the output dir: > > save('/path/to/my/data.dat') > > or use the os modules built-in functions for cross-platform path handling: > > save(os.path.join(outdir, filename)) > >> B) Create a directory I tell it to save to if it doesn;t already exist > > You can use os.mkdir. mpl svn has a function cbook.mkdirs to > recursively make a directory path. > > JDH > - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Saving to a file in a specified directory (and creating said directory along the way)
On Thu, Nov 20, 2008 at 10:24 AM, Joshua Lippai <[EMAIL PROTECTED]> wrote: > Hey, > > I'm working on a project for which I would like to dump data into a > file in a specified directory (that doesn't necessarily exist yet). I > know matplotlib.mlab.save(fname, X) will only work if I want to save > data from an array/list to a file in the current working directory. Is > there an easy way using matplotlib to: > > A) Save a file to a specified directory rather than the current > working directory Just specify the full path to the output dir: save('/path/to/my/data.dat') or use the os modules built-in functions for cross-platform path handling: save(os.path.join(outdir, filename)) > B) Create a directory I tell it to save to if it doesn;t already exist You can use os.mkdir. mpl svn has a function cbook.mkdirs to recursively make a directory path. JDH - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Saving to a file in a specified directory (and creating said directory along the way)
Hey, I'm working on a project for which I would like to dump data into a file in a specified directory (that doesn't necessarily exist yet). I know matplotlib.mlab.save(fname, X) will only work if I want to save data from an array/list to a file in the current working directory. Is there an easy way using matplotlib to: A) Save a file to a specified directory rather than the current working directory B) Create a directory I tell it to save to if it doesn;t already exist Thanks in advance. Josh - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Hiding a subplot
On Thu, Nov 20, 2008 at 8:06 AM, Søren Nielsen <[EMAIL PROTECTED]> wrote: > Hi, > > I have a canvas with two subplot.. I want to be able to hide on of the > subplots by pushing a button and letting the remaining subplot fill the > entire canvas. > > If I use the set_visible(True) parameter I correctly remove one of the > subplots.. but the remaining subplot does not fill the canvas.. Anyone have > an idea of how to do this? You should be able to use the "change_geometry" method on the remaining subplot ax2.set_visible(False) ax1.change_geometry(1,1,1) fig.canvas.draw() JDH - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Hiding a subplot
Hi, I have a canvas with two subplot.. I want to be able to hide on of the subplots by pushing a button and letting the remaining subplot fill the entire canvas. If I use the set_visible(True) parameter I correctly remove one of the subplots.. but the remaining subplot does not fill the canvas.. Anyone have an idea of how to do this? Thanks, Soren - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] general matplotlib usage questions
Dear ALL, In due time, I intend to compile as many suggestions and tips as possible to eventually create a "How-To" list for the superb Basemap module, like the very useful one which is on the Matplotlib home page. HTH Cheers, 2008/11/20 John Hunter <[EMAIL PROTECTED]>: > On Thu, Nov 20, 2008 at 7:12 AM, Darren Dale <[EMAIL PROTECTED]> wrote: > >> You can use the subplot_adjust button on the toolbar for some degree of >> customization. But in general, it can be a somewhat time consuming to get >> the layout just right. I think it would be difficult for mpl to determine >> what the appropriate axes position should be given a certain figure and text >> size. > > There is a recipe on the web site for automatically shifting the left > side of the subplot over to make room for the ylabels > > > http://matplotlib.sourceforge.net/faq/howto_faq.html#automatically-make-room-for-tick-labels > > It might be nice to make an option to handle the simple case > automatically, to expand or shrink the subplots so the text fits w/o > too much padding on any side. > > JDH > > - > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Dr. Mauro J. Cavalcanti Ecoinformatics Studio P.O. Box 46521, CEP 20551-970 Rio de Janeiro, RJ, BRASIL E-mail: [EMAIL PROTECTED] Web: http://studio.infobio.net Linux Registered User #473524 * Ubuntu User #22717 "Life is complex. It consists of real and imaginary parts." - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] general matplotlib usage questions
On Thu, Nov 20, 2008 at 1:21 PM, John Hunter <[EMAIL PROTECTED]> wrote: > There is a recipe on the web site for automatically shifting the left > side of the subplot over to make room for the ylabels > > > http://matplotlib.sourceforge.net/faq/howto_faq.html#automatically-make-room-for-tick-labels That's great - is there anything similar for axis labels (I haven't been using long tick labels - the problem I have is normal x and y axis labels are cut off) - or will that example also work? Thanks, Robin - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] general matplotlib usage questions
Sorry! Forgot to send to the list since the reply-to isn't set properly... Thanks very much for your reply! On Thu, Nov 20, 2008 at 1:12 PM, Darren Dale <[EMAIL PROTECTED]> wrote: > I think I know what causes this, I saw something similar in the Qt backends > a while back. When the mouse cursor enters the axes, the coordinates of the > cursor are reported in the statusbar/toolbar. The backend needs to be > configured so this text widget would rather run off the end of the window > than resize the window. I don't know how this is done in Tk, I've never > worked with that GUI library. Now you point it out it is clear that that is what is causing it. I'm using python.org python on a Mac and it's not clear to me how best to install Qt - so at the moment Tk is the only working backend I have. > You can use the subplot_adjust button on the toolbar for some degree of > customization. But in general, it can be a somewhat time consuming to get > the layout just right. I think it would be difficult for mpl to determine > what the appropriate axes position should be given a certain figure and text > size. I don't know about the widget - that is fantastic and it will make a huge difference... It is slightly confusing since I have been working with the set_position type numbers, but being able to change them interactively will save a lot of time. Another thing I've noticed is that the pdf output is always slightly different to the displayed output - for example some text might be cut off on the interactive view, but the saved pdf is fine... Is this also a known behaviour? Thanks again, Robin - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] general matplotlib usage questions
On Thu, Nov 20, 2008 at 7:12 AM, Darren Dale <[EMAIL PROTECTED]> wrote: > You can use the subplot_adjust button on the toolbar for some degree of > customization. But in general, it can be a somewhat time consuming to get > the layout just right. I think it would be difficult for mpl to determine > what the appropriate axes position should be given a certain figure and text > size. There is a recipe on the web site for automatically shifting the left side of the subplot over to make room for the ylabels http://matplotlib.sourceforge.net/faq/howto_faq.html#automatically-make-room-for-tick-labels It might be nice to make an option to handle the simple case automatically, to expand or shrink the subplots so the text fits w/o too much padding on any side. JDH - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] general matplotlib usage questions
On Thursday 20 November 2008 06:43:48 am Robin wrote: > Hi, > > I think matplotlib is a terrific tool, and it is a major component of > the open source toolset that has allowed me to stop using Matlab. > > But, whenever it comes to producing publication plots, there are a few > things I always find challenging - and I'm wondering if I'm doing > things wrong. > > First, what backend do people recommend for use on OS X? At the moment > I am using TkAgg. But is there any backend that will behave as a > proper OS X application ie allow window switching with cmd-`, maybe > allow use of the maximise button etc.? > > When producing publication size plots - ie 3x3 in or smaller (that > usually appear very small in the interactive window) there is an > annoying behaviour where any mouse over the graph seems to resize it - > the plot jumps around in size as I move the mouse over it. This is > mainly annoying because it means when producing a batch of plots for > later use, I have to be very careful not to mouse over, since once I > do that, I can no longer be sure it will return to the same size, so > the final set of images would have different sizes. If I accidently > mouse over I have to go back and recreate the plot. Is this a property > of the backend I am using? I think I know what causes this, I saw something similar in the Qt backends a while back. When the mouse cursor enters the axes, the coordinates of the cursor are reported in the statusbar/toolbar. The backend needs to be configured so this text widget would rather run off the end of the window than resize the window. I don't know how this is done in Tk, I've never worked with that GUI library. > Again, when working with small sizes, the procedure for chaning the > size of the figure is quite involved. As well as the standard problem > of making sure the text fits, nothing overlaps the image etc. > matplotlib doesn't seem to position the axes correctly in the figure - > the labels are usually cut off. So I have to manually experiment with > ax.set_position() by trial and error until I find a solution that > looks OK - but of course if I later change the size of the figure I > have to repeat this procedure. Is there an easier way to do this? You can use the subplot_adjust button on the toolbar for some degree of customization. But in general, it can be a somewhat time consuming to get the layout just right. I think it would be difficult for mpl to determine what the appropriate axes position should be given a certain figure and text size. Darren - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Save a plot background
Hrafnkell Pálsson wrote: > > >> This will turn off the rendering of both the background rectangle as >> well as all the ticks and their associated labels, ticklines and >> gridlines. Perhaps Jeff can advise you vis-a-vis the basemap api what >> the equivalent is >> >> > > Ok, I tested your example and see what you mean. > But if I understood you correctly this won't allow me to retain the > watermark and the dots I've used for marking cities. > It would be nice if I could retain the whole background, if it wouldn't > matter whether I retrieved the background or actually plotted it. > But even just avoiding plotting the coastline every time would save a lot of > time. > > > > >> Perhaps Jeff can advise you vis-a-vis the basemap api what >> the equivalent is >> >> > > Could you, Jeff, give me a nudge in the right direction? I've read through > the basemap documentation but didn't notice anything that might help. > > Hrafnkell > Hrafnkell: Had some time this morning, so I used John's method to create a working Basemap example: import matplotlib matplotlib.use('Agg') from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt # this example shows how to save a map background and # reuse it in another figure. # make sure we have all the same properties on all figs figprops = dict(figsize=(8,6), dpi=100, facecolor='white') # generate the first figure. fig1 = plt.figure(1,**figprops) ax1 = fig1.add_subplot(111) # create basemap instance, plot coastlines. map = Basemap(projection='moll',lon_0=0) map.drawcoastlines() map.drawmapboundary(fill_color='aqua') map.fillcontinents(color='coral',lake_color='aqua') fig1.canvas.draw() background = fig1.canvas.copy_from_bbox(fig1.bbox) fig1.savefig('figure1.png', dpi=100) # generate the second figure, re-using the background # from figure 1. fig2 = plt.figure(2,frameon=False,**figprops) ax2 = fig2.add_subplot(111, frameon=False, xticks=[], yticks=[]) # restore previous background. fig2.canvas.restore_region(background) # draw parallels and meridians on existing background. map.drawparallels(range(-90,90,30)) map.drawmeridians(range(-180,180,60)) fig2.savefig('figure2.png', dpi=100) I've added this to the basemap examples directory as save_background.py HTH, -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/PSD1FAX : (303)497-6449 325 BroadwayBoulder, CO, USA 80305-3328 - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Another question
Mauro Cavalcanti wrote: > Dear ALL, > > Another (this time possibly quite silly) question: how can I make a > Basemap cover entirely the display area of the GUI backend (ie., > without the top, bottom, left, right spaces)? > > I tried something like: > > self.figure = Figure() > self.figure.subplots_adjust(left=-0.01, bottom=-0.750, right=1.0, top=1.55) > > but could not control the bottom (or top) margins. > > Thanks in advance for any hints. > > Best regards, > > Mauro: You'll have to create a figure with the same aspect ratio as the map, and then add an axes to the figure that fills the entire figure (i.e. fig.add_axes([0,0,1,1]). The `aspect` Basemap instance variable tells you the aspect ratio of the map. For instance, in the wx embedding example you sent me, the map.aspect = 0.5. Therefore, you would need to create a figure canvas that is twice as wide as it is high, like this self.figure = Figure(figsize=(10,5)) then add an axes instances that fills the figure completely self.ax = self.figure.add_axes([0,0,1,1]) Note that you will not have any room for labels if you do this. HTH, -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/PSD1FAX : (303)497-6449 325 BroadwayBoulder, CO, USA 80305-3328 - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Another question
Dear Eric, Thanks for your reply. This is surely not good news -- maybe an automatic shrinking mechanism could be added in a future version of Matplotlib (this would be useful not only with maps, but with other plots as well)? Regards, 2008/11/20 Eric Firing <[EMAIL PROTECTED]>: > Mauro Cavalcanti wrote: >> >> Dear ALL, >> >> Another (this time possibly quite silly) question: how can I make a >> Basemap cover entirely the display area of the GUI backend (ie., >> without the top, bottom, left, right spaces)? >> >> I tried something like: >> >> self.figure = Figure() >> self.figure.subplots_adjust(left=-0.01, bottom=-0.750, right=1.0, >> top=1.55) >> >> but could not control the bottom (or top) margins. > > The reason is that a map has a fixed aspect ratio, and there is no mechanism > for automatically shrinking the appropriate figure dimension to eliminate > extra space. You will have adjust the figure dimensions manually. > > Eric > >> >> Thanks in advance for any hints. >> >> Best regards, >> > > -- Dr. Mauro J. Cavalcanti Ecoinformatics Studio P.O. Box 46521, CEP 20551-970 Rio de Janeiro, RJ, BRASIL E-mail: [EMAIL PROTECTED] Web: http://studio.infobio.net Linux Registered User #473524 * Ubuntu User #22717 "Life is complex. It consists of real and imaginary parts." - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] general matplotlib usage questions
Hi, I think matplotlib is a terrific tool, and it is a major component of the open source toolset that has allowed me to stop using Matlab. But, whenever it comes to producing publication plots, there are a few things I always find challenging - and I'm wondering if I'm doing things wrong. First, what backend do people recommend for use on OS X? At the moment I am using TkAgg. But is there any backend that will behave as a proper OS X application ie allow window switching with cmd-`, maybe allow use of the maximise button etc.? When producing publication size plots - ie 3x3 in or smaller (that usually appear very small in the interactive window) there is an annoying behaviour where any mouse over the graph seems to resize it - the plot jumps around in size as I move the mouse over it. This is mainly annoying because it means when producing a batch of plots for later use, I have to be very careful not to mouse over, since once I do that, I can no longer be sure it will return to the same size, so the final set of images would have different sizes. If I accidently mouse over I have to go back and recreate the plot. Is this a property of the backend I am using? Again, when working with small sizes, the procedure for chaning the size of the figure is quite involved. As well as the standard problem of making sure the text fits, nothing overlaps the image etc. matplotlib doesn't seem to position the axes correctly in the figure - the labels are usually cut off. So I have to manually experiment with ax.set_position() by trial and error until I find a solution that looks OK - but of course if I later change the size of the figure I have to repeat this procedure. Is there an easier way to do this? Thanks, Robin - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] cbook.is_scalar('foo') is False
Hello, It seems to me there is a bug in matplotlib 0.98.3 (or at least a change from previous version). >>> matplotlib.cbook.is_scalar('foo') False I would expect this to be True (otherwise, matplotlib.cbook.flatten(['foo']) enters an infinite recursive loop). It used to be (0.98.0): return is_string_like(obj) or not iterable(obj) and now (0.98.3): return not is_string_like(obj) and not iterable(obj) If it is by purpose, could someone explain it to me ? I'll then have to change my code accordingly. Thanks a lot in advance, Cyrille Rosset. - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users