[Matplotlib-users] MPL/Pylab install woes
I'm having some problems installing matplotlib (actually PyLab, see below). Googling has revealed nothing, perhaps someone might recognise these symptoms.The technical set up: OSX 10.4, MPL 0.87.4, numeric, numarray and numpy installed.While I've successfully installed and used MPL before, this is a new MacBook and so it's the first time it's been installed here. (Caveat: MPL may have been installed silently in an egg or a package that I used to install another package, like a SciPy distribution.) I built and installed MPL as usual. this appears to be fine and `import matplotlib` works ok. However the problem comes when I go to `import pylab`. Initially it complains that it cannot import pylab because it fails on line 74 of `matplotlib/numerix/__init__.py` where `Matrix = matrix`.Investigation showed that just above that position, numpy was being used as the numerical library and the import was thus: import numpy.oldnumeric as numpy from numpy.oldnumeric import *However, oldnumeric doesn't define a term "matrix". Setting MPL to use Numeric instead of Numpy, this step is passed but I run into the next error, also at the "import pylab" stage: 21:15:23: Debug: ../src/common/object.cpp(224): assert "sm_classTable->Get(m_className) == NULL" failed: class already in RTTI table - have you used IMPLEMENT_DYNAMIC_CLASS() twice (may be by linking some object module(s) twice)? ../src/common/object.cpp(224): assert "sm_classTable->Get(m_className) == NULL" failed: class already in RTTI table - have you used IMPLEMENT_DYNAMIC_CLASS() twice (may be by linking some object module(s) twice)?Initially I thought that this may have been the result of old settings hanging around, but I cleaned all vestigaes of MPL & PyLab from my system and got a fresh copy of the MPL source, before trying again. Same result.Any ideas on where I should look next? Apart from a downgrade, I'm at a loss.p --Dr Paul-Michael Agapow, VieDigitale / Institute of Animal Health[EMAIL PROTECTED] / [EMAIL PROTECTED] - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] MPL/Pylab install woes
On Monday 04 September 2006 05:20, Paul-Michael Agapow wrote: > I'm having some problems installing matplotlib (actually PyLab, see > below). Googling has revealed nothing, perhaps someone might > recognise these symptoms. mmh, you didn't check the mailing list before, did you ;) You didn't precise the version of numpy you were using, I gonna guess that it's at least 1.0b1, right ? MPL 0.87.4 is NOT compatible with this version of numpy. However, the svn version of matplotlib is, and works quite well. Please upgrade MPL, or wait a couple of days for the crew to release 0.87.5. - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] More than 9 subplots in Figure?
I'm a python newbie, using matplotlib 0.87.3. My code works, as long as I limit myself to 9 subplots. But, I need more than 9. Relevant parts of the code: from matplotlib.figure import Figure import pylab f = Figure(figsize=(5,4), dpi=100) plot1 = f.add_subplot((10,1,1), ylabel='Pitch (' + degreeChar + ')') I get an error like: Traceback (most recent call last): File "Flt_Test_Data_Review.py", line 726, in ? create_mpl_plots() File "Flt_Test_Data_Review.py", line 246, in create_mpl_plots plot1 = f.add_subplot((10,1,1), ylabel='Pitch (' + degreeChar + ')') File "/sw/lib/python2.4/site-packages/matplotlib/figure.py", line 472, in add_subplot a = Subplot(self, *args, **kwargs) File "/sw/lib/python2.4/site-packages/matplotlib/axes.py", line 4316, in __init__ SubplotBase.__init__(self, fig, *args) File "/sw/lib/python2.4/site-packages/matplotlib/axes.py", line 4208, in __init__ raise ValueError('Argument to subplot must be a 3 digits long') ValueError: Argument to subplot must be a 3 digits long subplot accepts a tuple in other places, so I would have expected the same behaviour here. Is this a bug that is fixed in a newer matplotlib version, in which case I will try to upgrade. Or, is there some other way to do my code that will work? Thanks, Kevin Horton Ottawa, Canada - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] matplotlib, GTK and Threads
I have run into a problem with matplotlib, GTK and Threading.The program basically gets data over RS232 and if a certain command is sent the data is plottedSo far the program is pretty mature and data can be read via RS232 and written to RS232 and the GUI is updated (text-widgets) accordinglyThe problem I have with with the non-GUI thread calling the "plot" function.Within the GTK-GUI class I added a method that basically plots a SINE-wave when a button is pressed it plots another SINE-wave, basically just proof-of-concept before I got onto the date via RS232The thread-code to extract data (for plotting) via RS232 works fine but when the thread calls a GUI method to update the graph it locks upCODE-SNIPPITSclass low_level(threading.Thread): def __init__(self,Reg,GUI): super(low_level, self).__init__() self.timer = threading.Timer(3.0,self.__SetTimerState) self.Reg = Reg self.GUI = GUI self.RUN = True self.timer_exp = False self.LOCAL_LIST = [] self.WRITELIST = []... def __Capture(self): DATA = "" self.__Write(self.Reg.MON_Addr,self.Reg.MON [-1]) tmp = [x for x in self.Reg.CAPTURE_REQ if x >0 and x not in locals()["_[1]"]] tmp.insert(0,0) for i in range(int(self.Reg.CAPTURE_SAMPLES)): self.__Write(127) for x in tmp: t = self.__ReadData( self.Reg.MON_MASK[x][1]) if t == '::ERROR::': print "Plotting data fault!!" break DATA[x].append(t) DAT = [DATA[0]] for x in self.Reg.CAPTURE_REQ: if x <1: DAT.append(None) else: DAT.append(DATA[x]) gtk.threads_enter()#updating GUI section try: self.GUI.ThreadGraph(DAT) finally: gtk.threads_leave() self.Reg.CAPTURE = False.gtk.gdk.threads_init ()class appgui(object): def __init__(self,Reg): super(appgui, self).__init__() self.Reg = Reg self.gladefile=GLADE_FILE self.windowname='ESC' self.wTree=gtk.glade.XML (self.gladefile,self.windowname) dic = {'on_quit_button_clicked' : self.QuitClicked,##callback dictionary 'on_connect_button_clicked' : self.Connect, 'on_save_conf_clicked' : self.Save , 'on_load_conf_clicked' : self.Load, 'on_upload_clicked' : self.Upload ,#GetRW, 'on_capture_clicked' : self.Capture, 'on_startstop_clicked' : self.StartStop, 'on_window_destroy' : (gtk.main_quit)} self.wTree.signal_autoconnect(dic) self.f = self.wTree.get_widget self.GraphData(INIT_G)... def GraphData(self,DATA): COLOUR = ['b','g','r','c','m','y','k'] try: self.canvas.destroy() self.toolbar.destroy() except:pass self.figure = Figure(figsize=(6,3), dpi=100)#{{{ self.axis = self.figure.add_subplot (111) self.axis.grid(True) self.axis.set_xlabel('Time (s)') for x in range(1,len(DATA)): if DATA[x] == None: continue self.axis.plot(DATA[0],DATA[x],COLOUR[x-1],linewidth=2.0) self.canvas = FigureCanvas(self.figure) # a gtk.DrawingArea self.canvas.show () self.graphview = self.wTree.get_widget('vboxgraph') self.graphview.pack_start (self.canvas, True, True) self.toolbar = NavigationToolbar(self.canvas,self.wTree.get_widget('ESC')) self.graphview.pack_start(self.toolbar, False, False)#}}}...if __name__ == '__main__': Reg = Register() app=appgui(Reg) LL = low_level(Reg,app) LL.start() gtk.threads_enter() gtk.main() gtk.threads_leave() LL.stop ()As it stands with this locks up, if I change the code such that when I press the widget that starts the "Capture" fn from the thread, BUT that doesn't update the plotand if I add another button and in pressing that (NOTE that button's code would be part of the GUI-class) calls the GraphData function then it works. It seems even using the gtk.threads_enter and gtk.threads_leave with a matplotlib embedded into a GTK windows does not work and any graph modifications MUSTbe called directly from the GUI-Class.Any idea how to make matplotlib work well with GTK & Threads? - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] axis elements and zorder
> "Michael" == Michael Fitzgerald <[EMAIL PROTECTED]> writes: Michael> Hi all, Michael> I have a question about zorder and Axis elements. I read Michael> in the thread titled "zorder not working for grid Michael> lines??" that since grid lines are Axis elements, they Michael> don't respect the zorder. It's possible to set grid Michael> lines below other plot elements with Michael> Axis.set_axisbelow(). However, I have a case where I Michael> want grid lines to be below my plot elements, but I want Michael> the ticks to be above them (test code attached). As it Michael> stands, they can be either both below or both above. Michael> Has anyone found a way around this limitation? Is having Michael> zorder apply to Axis elements on the wishlist? It would be a cleaner solution if the grid and ticks respected the zorder property, but it's not trivial to do it that way given the current design. Instead, as you've noticed, you need to set the axisbelow property on the axes ax.set_axisbelow(True) but this doesn't solve your problem of needing the ticks above and grid below You might try setting both above, but setting the alpha on the grid so you can at least see through it. Yes, fixing this is on the list of things to do, but doing it right would requires a significant refactoring of the way ticks are handled. JDH - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Postscript ouput on OS X problem.
Hiya, i'm having a problem getting a valid postscript file produced on OS X. Using the example subplot_demo.py, modified to include the line: savefig('subplot_demo') in the place of the show() command, and running it using: python subplot_demo.py -dPS Produces the .ps file (available here for reference: http://www.irbdavid.com/misc/subplot_demo.ps ), which can't be opened by Preview on os x - says its can't convert it to PDF & cant open the file. Checked the permissions etc on the file and they're fine. Its pretty much a default installation of matplotlib etc, and output displays fine on screen, using the wxPython / wxAgg thing (I think that's what i mean :D ) Any suggestions? Regards, Dave - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] More than 9 subplots in Figure?
> "Kevin" == Kevin Horton <[EMAIL PROTECTED]> writes: Kevin> subplot accepts a tuple in other places, so I would have Kevin> expected the same behaviour here. Is this a bug that is Kevin> fixed in a newer matplotlib version, in which case I will Kevin> try to upgrade. Or, is there some other way to do my code Kevin> that will work? You need to either do subplot(10,1,1) or tup = 10,1,1 subplot(*tup) subplot does not accept a tuple: it either accepts and integer, eg num = 311 subplot(num) or three args: numrows, numcols, num python let's you "unpack" tuple with the "*" operator. JDH - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Postscript ouput on OS X problem.
> "David" == David Andrews <[EMAIL PROTECTED]> writes: David> Hiya, i'm having a problem getting a valid postscript file David> produced on OS X. Using the example subplot_demo.py, David> modified to include the line: David> savefig('subplot_demo') David> in the place of the show() command, and running it using: David> python subplot_demo.py -dPS David> Produces the .ps file (available here for reference: David> http://www.irbdavid.com/misc/subplot_demo.ps ), which can't David> be opened by Preview on os x - says its can't convert it to David> PDF & cant open the file. Checked the permissions etc on David> the file and they're fine. David> Its pretty much a default installation of matplotlib etc, David> and output displays fine on screen, using the wxPython / David> wxAgg thing (I think that's what i mean :D ) We've noticed this on tiger several times. Some default system fault is causing troubles though we haven't identified which one. The recommended fix it to put the Vera fonts (which matplotlib ships with) first in your rc file (http://matplotlib.sf.net/matplotlibrc) and remove your ~/.matplotlib/ttf.cache before rerunning Ie, you fonts section of ex should look something like this: font.serif : Bitstream Vera Serif, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif font.sans-serif : Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif font.cursive: Apple Chancery, Textile, Zapf Chancery, Sand, cursive font.fantasy: Comic Sans MS, Chicago, Charcoal, Impact, Western, fantasy font.monospace : Bitstream Vera Sans Mono, Andale Mono, Nimbus Mono L, Courier New, Courier, Fixed, Terminal, monospace In future releases of mpl, this will be the default. JDH - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Postscript ouput on OS X problem.
Dave, I had the same problem as you. Here is a solution... Try editing your matplotlib rc file and change these font preferences font.serif : New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Bitstream Vera Serif, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif font.sans-serif : Lucida Grande, Verdana, Geneva, Lucida, Bitstream Vera Sans, Arial, Helvetica, Avant Garde, sans-serif font.cursive: Apple Chancery, Textile, Zapf Chancery, Sand, cursive font.fantasy: Comic Sans MS, Chicago, Charcoal, Impact, Western, fantasy font.monospace : Andale Mono, Bitstream Vera Sans Mono, Nimbus Mono L, Courier New, Courier, Fixed, Terminal, monospace by moving the bitstream fonts to the front. Next, you have to use LaTeX for all the 'text' you include in your plot. Add rc('text', usetex=True) at the begining of your Python script or modify your matplotlibrc file. Everything is working fine after that. Regards. Benoit David Andrews a écrit : > Hiya, i'm having a problem getting a valid postscript file produced on OS X. > > Using the example subplot_demo.py, modified to include the line: > > savefig('subplot_demo') > > in the place of the show() command, and running it using: > > python subplot_demo.py -dPS > > Produces the .ps file (available here for reference: > http://www.irbdavid.com/misc/subplot_demo.ps ), which can't be opened > by Preview on os x - says its can't convert it to PDF & cant open the > file. Checked the permissions etc on the file and they're fine. > > Its pretty much a default installation of matplotlib etc, and output > displays fine on screen, using the wxPython / wxAgg thing (I think > that's what i mean :D ) > > Any suggestions? > > Regards, > > Dave > > - > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Benoit Donnet Universite Catholique de Louvain Facultes des Sciences Appliquees - Departement d'Ingenierie Informatique (INGI) Place Sainte Barbe, 1 1348 Louvain-la-Neuve phone: +32 10 47 87 18 home page: http://rp.lip6.fr/~donnet [EMAIL PROTECTED] website: http://trhome.sourceforge.net - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] More than 9 subplots in Figure?
On 4 Sep 2006, at 10:54, John Hunter wrote: >> "Kevin" == Kevin Horton <[EMAIL PROTECTED]> writes: > Kevin> subplot accepts a tuple in other places, so I would have > Kevin> expected the same behaviour here. Is this a bug that is > Kevin> fixed in a newer matplotlib version, in which case I will > Kevin> try to upgrade. Or, is there some other way to do my code > Kevin> that will work? > > You need to either do > > subplot(10,1,1) > > or > > tup = 10,1,1 > subplot(*tup) > > subplot does not accept a tuple: it either accepts and integer, eg > > num = 311 > subplot(num) > > or three args: numrows, numcols, num > > python let's you "unpack" tuple with the "*" operator. That works. Thank you very much. Kevin Horton Ottawa, Canada - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Saving in SVG
> ">" == <[EMAIL PROTECTED]> writes: >> line 154, in draw_image image64 = base64.b64encode >> (imfile.read()) AttributeError: 'module' object has no >> attribute 'b64encode' >> Is there something I'm missing ? It looks like the svg module was written assuming the python2.4 version of the base64 standard library -- the b64encode method does not appear to be available in python2.3. I replaced this with base64.encodestring which appears to work under python2.3 and 2.4. If you have access to svn, you can simply update. Otherwise replace "b64encode" with "encodestring" in backend_svg. JDH - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] installation
> "Darren" == Darren Dale <[EMAIL PROTECTED]> writes: Darren> It is strongly discouraged to try to build matplotlib from Darren> source on windows. Setting up your windows environment to Darren> build the source is difficult and time consuming. Please Darren> use the windows installers at the download site instead. I wouldn't go as far to say it is strongly discouraged; merely that it is not for the faint of heart. For enterprising souls who know there way around a compiler, I would encourage it, since we would have more hands to help with building and testing svn on windows. As for the specific error messages, it looks like you do not have the tk development headers installed or for some reason your build is not finding them. Please see the header for win32 in setupext.py and references to the READMEs therein if you want to pursue this. JDH - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] changing sharex after ?
> "Samuel" == Samuel GARCIA <[EMAIL PROTECTED]> writes: Samuel> Hello, I am writing a little GUI with PyQT4 and Samuel> matplotlib. So it is embeded. I want that feature for Samuel> the user : he can decided after ploting some data to Samuel> synchronize 2 graph with the x axis for the zoom. Samuel> So this method would be very useful for me. Maybe I can Samuel> write it. Do you have a idea of all the variables Samuel> involved in the sharex feature ? It doesn't look too easy, without some additional methods in the BBox extension code. I'll look into it. JDH - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] tick label hiding problem
> "Michael" == Michael Fitzgerald <[EMAIL PROTECTED]> writes: Michael> I placed that command before the ax.get_xticklabels(), Michael> and no dice. Michael> Thanks for looking into this, Mike I took a look at the formatter code and it turns out it *does* know the list of locations it has to format. I was wrong about this in my previous post. The formatter has a locs attribute you can inspect to see how many ticks there are. So you should be able to do something like class MyFormatter(ScalarFormatter): def __call__(self, x, pos=None): N = len(self.locs) if pos==0: return ''# turn off first elif pos==(N-1): return '' # turn off last else: return ScalarFormatter(self, x, pos) and you can do other things similarly, eg to turn off every other tick if (pos%2)==0: return '' If you want to get very clever with turning on and off certain ticks, you can also create a custom locator derived from the Locator class you are using. JDH - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib, GTK and Threads
Jon Roadley-Battin wrote: > The problem I have with with the non-GUI thread calling the "plot" > function. That's your problem -- you should only call the GUI code (including matplotlib, which eventually calls GTK) from a single thread. I suggest looking at the Queue module to pass your data to the GUI thread if it's not too much. If it's more, you could use threading.Lock() to regulate access to a giant array or something. -Andrew - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] vertical alignment of text
Hi all, Is there a way to align text vertically so that the characters sit on a continuous line ? When I dotext(.5, .5, 'abc', verticalalignment='center')text(.6, .5, 'pqr', verticalalignment='center') both words are not aligned since the bars of p and q push the text upwards. I get similar problems with 'top' and 'bottom' alignment.Thanks, David - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] vertical alignment of text
> "David" == David Huard <[EMAIL PROTECTED]> writes: David> Hi all, Is there a way to align text vertically so that the David> characters sit on a continuous line ? When I do text(.5, David> .5, 'abc', verticalalignment='center') text(.6, .5, 'pqr', David> verticalalignment='center') both words are not aligned David> since the bars of p and q push the text upwards. I get David> similar problems with 'top' and 'bottom' alignment. Sadly not. We need to add an additional alignment flag to support this. Currently, we align by the bounding box rather than the text baseline. JDH - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] 0.86 vs 0.87 plot difference?
Hi, I have 2 questions. First, after upgrading from 0.86 to 0.87, my graphics aren't the same. On 0.87, they are "squeezed" horizontally, which is bad. You can see an exemple on those (SVG exported to PNG via Inkscape): http://nbigaouette.inrs-emt.homelinux.net/linux/matplotlib_0.86.2.png http://nbigaouette.inrs-emt.homelinux.net/linux/matplotlib_0.87.4.png The original SVGs are : http://nbigaouette.inrs-emt.homelinux.net/linux/matplotlib_0.86.2.svg http://nbigaouette.inrs-emt.homelinux.net/linux/matplotlib_0.87.4.svg What is causing this? Did something changed that I need to adapt my code or is it a bug? Second, as you can see on the PNG, I can't see well the TeX characters (look at the "x" axis, it should be "x (um)" with "u" being mu, the micron symbol http://en.wikipedia.org/wiki/Mu_%28letter%29). Those graphics are saved directly to SVG, without any GUI. If I display the graphic on my screen (without saving to SVG), I get that screen : http://nbigaouette.inrs-emt.homelinux.net/linux/matplotlib_0.86.2_X.png If I then save the file to PNG, I get this one : http://nbigaouette.inrs-emt.homelinux.net/linux/matplotlib_0.86.2_X_save.png witch is ok. But if I save to SVG, I get this one : http://nbigaouette.inrs-emt.homelinux.net/linux/matplotlib_0.86.2_X_save.svg Exported to PNG, the latter is : http://nbigaouette.inrs-emt.homelinux.net/linux/matplotlib_0.86.2_X_save_svg.png Clearly, matplotlib's SVG backend doesn't seems to support TeX characters. Is it supposed to? Is it possible to hope it will? Thanks! Nicolas - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] installation
On Monday 04 September 2006 12:15 pm, John Hunter wrote: > > "Darren" == Darren Dale <[EMAIL PROTECTED]> writes: > > Darren> It is strongly discouraged to try to build matplotlib from > Darren> source on windows. Setting up your windows environment to > Darren> build the source is difficult and time consuming. Please > Darren> use the windows installers at the download site instead. > > I wouldn't go as far to say it is strongly discouraged; merely that it > is not for the faint of heart. For enterprising souls who know there > way around a compiler, I would encourage it, since we would have more > hands to help with building and testing svn on windows. As for the > specific error messages, it looks like you do not have the tk > development headers installed or for some reason your build is not > finding them. Please see the header for win32 in setupext.py and > references to the READMEs therein if you want to pursue this. My mistake. Not for the faint of heart is a much better way of putting it. - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] 0.86 vs 0.87 plot difference?
On Monday 04 September 2006 14:28, Nicolas Bigaouette wrote: > Hi, > What is causing this? Did something changed that I need to adapt my code > or is it a bug? Check the "aspect" keyword of your image, and try to set it to 'auto'. > Clearly, matplotlib's SVG backend doesn't seems to support TeX > characters. Is it supposed to? Yes. http://matplotlib.sourceforge.net/matplotlib.texmanager.html > Is it possible to hope it will? Pass - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] axprops?
I was doing some Googling to look for a way to solve a problem controlling sharex, and came across an example using axprops. This solved my problem, but now I wonder what other aspects I can control with axprops, or other similar methods. Where is axprops documented? I've looked via pydoc, and in the pdf documentation, but no dice. Thanks, Kevin Horton Ottawa, Canada - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] axprops?
> "Kevin" == Kevin Horton <[EMAIL PROTECTED]> writes: Kevin> I was doing some Googling to look for a way to solve a Kevin> problem controlling sharex, and came across an example Kevin> using axprops. This solved my problem, but now I wonder Kevin> what other aspects I can control with axprops, or other Kevin> similar methods. Where is axprops documented? I've looked Kevin> via pydoc, and in the pdf documentation, but no dice. axprops is simply a dictionary holding key/value pairs. It is not part of the matplotlib API. Any function that takes keyword arguments, such as the Axes constructor, can take a dictionary with keyword/value pairs using the following syntax a = Axes(fig, rect, **d) where d is a dictionary. This is part of python, not matplotlib proper, but because matplotlib makes extensive use of keyword arguments, it is a handy trick to remember. When I am creating several axes with shared properties, I often use it to have a single customization point axprops = dict(axisbg='yellow', xlim=(0,1)) for i in range(N): fig.add_subplot(N,1,i+1, **axprops) or something like that. But I don't think this solves your problem: you can use this to turn on the sharex feature but not to turn it off once it is already on. As for your question about where to find the aspects of the Axes that can be controlled this way, you can do it by consulting the class documentation at http://matplotlib.sf.net/matplotlib.axes.html and looking for methods that start with "set_" or by firing up an interactive shell (see http://matplotlib.sf.net/interactive.html) and using setp introspection In [2]: ax = subplot(111) In [3]: setp(ax) adjustable: ['box' | 'datalim'] alpha: float anchor: ['C', 'SW', 'S', 'SE', 'E', 'NE', 'N', 'NW', 'W'] animated: [True | False] aspect: ['auto' | 'equal' | aspect_ratio] autoscale_on: True|False axis_bgcolor: any matplotlib color - see help(colors) axis_off: void axis_on: void axisbelow: True|False clip_box: a matplotlib.transform.Bbox instance clip_on: [True | False] cursor_props: a (float, color) tuple figure: a Figure instance frame_on: True|False label: any string lod: [True | False] navigate: True|False navigate_mode: unknown position: len(4) sequence of floats title: str transform: a matplotlib.transform transformation instance visible: [True | False] xlabel: str xlim: len(2) sequence of floats xscale: ['log' | 'linear' ] xticklabels: sequence of strings xticks: sequence of floats ylabel: str ylim: len(2) sequence of floats yscale: ['log' | 'linear'] yticklabels: sequence of strings yticks: sequence of floats zorder: any number - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] 0.86 vs 0.87 plot difference?
> "Nicolas" == Nicolas Bigaouette <[EMAIL PROTECTED]> writes: Nicolas> Clearly, matplotlib's SVG backend doesn't seems to Nicolas> support TeX characters. Is it supposed to? It does -- the only trick is you need to make sure your svg viewer can see the fonts. Currently we use the bakoma cm*.ttf fonts that ship with matplotlib, so make sure these fonts are in your svg viewer's font path. In postscript, we embed the truetype fonts directly into the PS file which makes for large output files but helps portability across ps viewers. We were unable to figure out how to do this with SVG. Nicolas> Is it possible to hope it will? One can always hope :-) JDH - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib, GTK and Threads
Message: 2Date: Mon, 04 Sep 2006 09:56:22 -0700From: Andrew Straw < [EMAIL PROTECTED]>Subject: Re: [Matplotlib-users] matplotlib, GTK and ThreadsTo: Jon Roadley-Battin <[EMAIL PROTECTED]>, matplotlib-users@lists.sourceforge.netMessage-ID: <[EMAIL PROTECTED]>Content-Type: text/plain; charset=ISO-8859-1Jon Roadley-Battin wrote: > The problem I have with with the non-GUI thread calling the "plot"> function.That's your problem -- you should only call the GUI code (includingmatplotlib, which eventually calls GTK) from a single thread. I suggest looking at the Queue module to pass your data to the GUI thread if it'snot too much. If it's more, you could use threading.Lock() to regulateaccess to a giant array or something.-Andrew I was pretty convinced that is was due to the threading since early one with GTK I had some issues with it.I was hoping that there was some form of enable_threading method with matplotlib.The problem that makes this hard and what forced me down the thread route is that the thread polls the RS232 every second or so, thus it needs to be separate (ie threaded) from the GUI, this have been done with hte enter/leave thread statement for GTK. But now it seems that updating the Matplotlib MUST be done from within the GUI and not initilised by another thread (be it if the thread enabled GTK events) I must think of a way around it.The only other option is to start a GTK timer event (did use this originally, but they had problems with the whole asyncronous of the RS232) that every second check's if my plot array has been updated (via some flag) and if it has then update plot, this way it would be within the GUI-class I stipped the code down to its most basic instance (the window will have to be dragged wider)is there any thread_init for matplotlib. short of having a timer within the GUI class that checks if any new data is present I cant see a way around this. It has to be done this way, the GUI doesn't instigate things, the GUI only reports things, the thread gets the data at set intervals and then updates the GUI #!/usr/bin/env python import threadingimport timeimport math import sysimport osimport pygtk if sys.platform == 'win32': os.environ['PATH'] += ';lib;' else: pygtk.require('2.0')import gtk import gobjectassert gtk.pygtk_version >= (1,99,16), 'pygtk should be >= 1.99.16' #import gtk.gladefrom pylab import * rcParams['numerix'] = 'numpy'import matplotlibmatplotlib.use ('GTK')from matplotlib.figure import Figurefrom matplotlib.axes import Subplot from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas TIME = range(360)VOLT = [math.sin(math.radians(x)) for x in TIME] VOLT2 = [2]*360VOLT3 = [x for x in range(360)] class my_thread(threading.Thread): def __init__(self,GUI): super(my_thread, self).__init__() self.GUI = GUI def run(self): time.sleep(10) gtk.threads_enter() try: self.GUI.Graph([TIME,VOLT3]) finally: gtk.threads_leave() gtk.gdk.threads_init()class GUI(object): def GUI_Plot(self,widget,event,data=""> self.Graph([TIME,VOLT2]) def delete_event(self,widget,event,data=""> return False def destroy(self,widget,data=""> gtk.main_quit() def __init__(self): super(GUI,self).__init__() self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_title("Matplotlib GTK test") self.window.connect("delete_event",self.delete_event) self.window.connect("destroy",self.destroy) self.window.set_border_width (10) self.box1 = gtk.VBox(False,0) self.window.add(self.box1) self.button = gtk.Button("GUI Plot") self.button.connect("clicked",self.GUI_Plot,None) self.box1.pack_start(self.button,True,True,0) self.button.show() self.box1.show() self.window.show() self.Graph([TIME,VOLT]) def Graph(self,DATA): try: self.canvas.destroy () self.toolbar.destroy() except:pass self.figure = Figure(figsize=(6,3), dpi=100)#{{{ self.axis = self.figure.add_subplot(111) self.axis.grid(True) self.axis.set_xlabel('Time (s)') self.axis.plot(DATA[0],DATA[1],linewidth=2.0) self.canvas = FigureCanvas( self.figure) # a gtk.DrawingArea self.canvas.show() self.graphview = self.box1 self.graphview.pack_start(self.canvas, True, True) def main(self): gtk.main() if __name__ == "__main__": A = GUI() B = my_thread(A) B.start() gtk.threads_enter() A.main() gtk.threads_leave () - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on A
Re: [Matplotlib-users] Postscript ouput on OS X problem.
For the benefit of the mailing list & developers, this fix works fine for me (OS X Tiger 10.4.7) Cheers John. Dave On 04/09/06, John Hunter <[EMAIL PROTECTED]> wrote: > > "David" == David Andrews <[EMAIL PROTECTED]> writes: > > David> Hiya, i'm having a problem getting a valid postscript file > David> produced on OS X. Using the example subplot_demo.py, > David> modified to include the line: > > David> savefig('subplot_demo') > > David> in the place of the show() command, and running it using: > > David> python subplot_demo.py -dPS > > David> Produces the .ps file (available here for reference: > David> http://www.irbdavid.com/misc/subplot_demo.ps ), which can't > David> be opened by Preview on os x - says its can't convert it to > David> PDF & cant open the file. Checked the permissions etc on > David> the file and they're fine. > > David> Its pretty much a default installation of matplotlib etc, > David> and output displays fine on screen, using the wxPython / > David> wxAgg thing (I think that's what i mean :D ) > > We've noticed this on tiger several times. Some default system fault > is causing troubles though we haven't identified which one. The > recommended fix it to put the Vera fonts (which matplotlib ships with) > first in your rc file (http://matplotlib.sf.net/matplotlibrc) and > remove your ~/.matplotlib/ttf.cache before rerunning > > Ie, you fonts section of ex should look something like this: > > > font.serif : Bitstream Vera Serif, New Century Schoolbook, Century > Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New > Roman, Times, Palatino, Charter, serif > font.sans-serif : Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, > Lucid, Arial, Helvetica, Avant Garde, sans-serif > font.cursive: Apple Chancery, Textile, Zapf Chancery, Sand, cursive > font.fantasy: Comic Sans MS, Chicago, Charcoal, Impact, Western, > fantasy > font.monospace : Bitstream Vera Sans Mono, Andale Mono, Nimbus Mono L, > Courier New, Courier, Fixed, Terminal, monospace > > In future releases of mpl, this will be the default. > > JDH > - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] installation
On 9/1/06, Kenny Ortmann <[EMAIL PROTECTED]> wrote: > hey guys i got the subversion from the site and I am trying to install it > on windows. > > I changed dir into the matplotlib dir that includes the setup.py file. > > run python setup.py install, and im getting a wierd error. i left the > topmost lines along with the error. has anyone seen anything like this > before? > > building 'matplotlib.enthought.traits.ctraits' extension > creating build\temp.win32-2.4\Release\lib > creating build\temp.win32-2.4\Release\lib\matplotlib > creating build\temp.win32-2.4\Release\lib\matplotlib\enthought > creating build\temp.win32-2.4\Release\lib\matplotlib\enthought\traits > C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c > /nologo /Ox > /MD /W3 /GX /DNDEBUG -Ic:\Python24\include -Ic:\Python24\PC > /Tclib/matplotlib/e > nthought/traits/ctraits.c > /Fobuild\temp.win32-2.4\Release\lib/matplotlib/enthoug > ht/traits/ctraits.obj > C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\link.exe /DLL > /nologo > /INCREMENTAL:NO /LIBPATH:c:\Python24\libs /LIBPATH:c:\Python24\PCBuild > /EXPORT: > initctraits > build\temp.win32-2.4\Release\lib/matplotlib/enthought/traits/ctraits > .obj /OUT:build\lib.win32-2.4\matplotlib\enthought\traits\ctraits.pyd > /IMPLIB:bu > ild\temp.win32-2.4\Release\lib/matplotlib/enthought/traits\ctraits.lib > building 'matplotlib.backends._tkagg' extension > C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c > /nologo /Ox > /MD /W3 /GX /DNDEBUG -Iwin32_static/include/tcl84 -I. -Isrc -Iswig > -Iagg23/incl > ude -I. -I. -Iwin32_static/include/tcl84\freetype2 -I.\freetype2 > -Isrc\freetype2 > -Iswig\freetype2 -Iagg23/include\freetype2 -I.\freetype2 -I.\freetype2 > -Ic:\Pyt > hon24\include -Ic:\Python24\PC /Tpsrc/_tkagg.cpp > /Fobuild\temp.win32-2.4\Release > \src/_tkagg.obj > _tkagg.cpp > src\_tkagg.cpp(28) : fatal error C1083: Cannot open include file: 'tk.h': > No suc > h file or directory > error: Command ""C:\Program Files\Microsoft Visual Studio .NET > 2003\Vc7\bin\cl.e > xe" /c /nologo /Ox /MD /W3 /GX /DNDEBUG -Iwin32_static/include/tcl84 -I. > -Isrc - > Iswig -Iagg23/include -I. -I. -Iwin32_static/include/tcl84\freetype2 > -I.\freetyp > e2 -Isrc\freetype2 -Iswig\freetype2 -Iagg23/include\freetype2 > -I.\freetype2 -I.\ > freetype2 -Ic:\Python24\include -Ic:\Python24\PC /Tpsrc/_tkagg.cpp > /Fobuild\temp > .win32-2.4\Release\src/_tkagg.obj" failed with exit status 2 You need to install the tcl/tk headers as Darren mentioned. I just install ActiveTcl and the build should pick up on it no problem. - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib, GTK and Threads
> "Jon" == Jon Roadley-Battin <[EMAIL PROTECTED]> writes: Jon> is there any thread_init for matplotlib. short of having a Jon> timer within the GUI class that checks if any new data is Jon> present I cant see a way around this. It has to be done this There isn't any such method. Would it work for you to update your line data / plot data and run canvas.draw_idle in a gtk timer, eg every second? Since you are only polling your RS232 every second or so, it seems like you could update your graph in a timer on roughly the same time scale w/o too much pain. I don't know mcuh about threading, but trying to make threads play nice with all the GUIs mpl supports seems daunting, and I prefer to offload that to external apps -- eg ipython in pylab mode. But if there is something we can add that will make your use case work better if the timer route doesn't work, feel free to suggest something... JDH - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib, GTK and Threads
I have a solution that works.The problem is in 1/2 GTK and threads. unfortunetly threads are needed in this instance, idle timers [orig tried with them] have their issues which added their own problems, threads gave alot more benefits then they then problems they solved (I have a forum-thread on a python forum about three methods I tried, for this instance threading is the only solution) Basically GTK can work with threads, the problem arrises when the thread want's to change the GUI (say a txt lable). GTK can be made "thread-safe" via calling gtk.gdk.threads_init() before gtk.main(). THEN every time the thread wants to change something, put it between gtk.threads_enter() gtk.threads_leave()calls.THIS only works for default GTK widgets and since a matplotlib window isn't a standard GTK widget it hard-locks the GUI.I have a solution to it, it is quite neat (it could be a fn wrapper, but don't know much abt fn wrappers) #!/usr/bin/env python import threading import time import math import sys import os import pygtk if sys.platform == 'win32': os.environ['PATH'] += ';lib;' else: pygtk.require('2.0') import gtk import gobject assert gtk.pygtk_version >= (1,99,16), 'pygtk should be >= 1.99.16' #import gtk.glade from pylab import * rcParams['numerix'] = 'numpy' import matplotlib matplotlib.use('GTK') from matplotlib.figure import Figure from matplotlib.axes import Subplot from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas TIME = range(360) VOLT = [math.sin(math.radians(x)) for x in TIME] VOLT2 = [2]*360 VOLT3 = [x for x in range(360)] def do_gui(fn,*args,**kw): def idle_func(): print "idle" gtk.threads_enter() try: fn(*args,**kw) finally: gtk.threads_leave() gobject.idle_add(idle_func) class my_thread(threading.Thread): def __init__(self,GUI): super(my_thread, self).__init__() self.GUI = GUI def run(self): time.sleep(10) #gtk.threads_enter() #try: # self.GUI.Graph([TIME,VOLT3]) #finally: # gtk.threads_leave() do_gui(self.GUI.Graph,[TIME,VOLT3]) gtk.gdk.threads_init() class GUI(object): def GUI_Plot(self,widget,event,data="" self.Graph([TIME,VOLT2]) def delete_event(self,widget,event,data="" return False def destroy(self,widget,data="" gtk.main_quit() def __init__(self): super(GUI,self).__init__() self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_title("Matplotlib GTK test") self.window.connect("delete_event",self.delete_event) self.window.connect("destroy",self.destroy) self.window.set_border_width(10) self.box1 = gtk.VBox(False,0) self.window.add(self.box1) self.button = gtk.Button("GUI Plot") self.button.connect("clicked",self.GUI_Plot,None) self.box1.pack_start(self.button,True,True,0) self.button.show() self.box1.show() self.window.show() self.Graph([TIME,VOLT]) def Graph(self,DATA): try: self.canvas.destroy() self.toolbar.destroy() except:pass self.figure = Figure(figsize=(6,3), dpi=100)#{{{ self.axis = self.figure.add_subplot(111) self.axis.grid(True) self.axis.set_xlabel('Time (s)') self.axis.plot(DATA[0],DATA[1],linewidth=2.0) self.canvas = FigureCanvas(self.figure) # a gtk.DrawingArea self.canvas.show() self.graphview = self.box1 self.graphview.pack_start(self.canvas, True, True) def main(self): gtk.main() if __name__ == "__main__": A = GUI() B = my_thread(A) B.start() gtk.threads_enter() A.main() gtk.threads_leave()basically another fn is created that has the threads_enter and threads_leave called, BUT they themselves are called within a gtk-idle call, this stops the GUI from hard-locking. I don't know if it is the best solution, but it is a solution. thanksOn 9/5/06, John Hunter < [EMAIL PROTECTED]> wrote:> "Jon" == Jon Roadley-Battin < [EMAIL PROTECTED]> writes:Jon> is there any thread_init for matplotlib. short of having aJon> timer within the GUI class that checks if any new data is Jon> present I cant see a way around this. It has to be done thisThere isn't any such method. Would it work for you to update yourline data / plot data and run canvas.draw_idle in a gtk timer, eg every second? Since you are only polling your RS232 every second orso, it seems like you could update your graph in a timer on roughlythe same time scale w/o too much pain.I don't know mcuh about threading, but trying to make threads play nice with all the GUIs mpl supports seems daunting, and I prefer tooffload that to external apps -- eg ipython in pylab mode. But ifthere is something we can add that will make your use c