[Matplotlib-users] circle not drawn correctly when axis is flipped
I'm trying to plot a circle AND flip an axis of the plot, but this leads to an inverted circle (diamond) being drawn. Is there any way to do this 'neatly' (besides, for example, manually editing the axis labels or using a many-sided polygon to fake a circle)? Note that the circle renders correctly with the PS backend Example code to reproduce the problem: import pylab as p x = p.rand(17) y = p.rand(17) p.scatter(x,y) p.gca().add_patch(p.Circle((0.5,0.5),0.2,fill=False)) p.axis([0.,1.,1.,0.]) p.gca().set_aspect('equal') p.show() Thanks for any help! Matt - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] using strpdate2num in load
Hi, I've a little problem with date conversion. I have a csv file which looks like : Data,Valor 15/01/2007, 6,700012000 12/01/2007, 6,659903000 11/01/2007, 6,701586000 I try to get date using function strpdate2num in load doing this : from pylab import datestr2num, load def comma_nb2float(A): return eval(A.replace(',','.')) dates, valor = load(file.csv,delimiter=',',converters={0:strpdate2num('%d/%m/%Y'),1:comma_nb2float},skiprows=1, usecols=(0,1),unpack=True) I got the following error message : --- exceptions.ValueErrorTraceback (most recent call last) /home/manu/Documents/Perso/../ipython console /usr/lib/python2.4/site-packages/matplotlib/mlab.py in load(fname, comments, delimiter, converters, skiprows, usecols, unpack) 1353 if usecols is not None: 1354 vals = line.split(delimiter) - 1355 row = [converterseq[j](vals[j]) for j in usecols] 1356 else: 1357 row = [converterseq[j](val) for j,val in enumerate(line.split(delimiter))] /usr/lib/python2.4/site-packages/matplotlib/dates.py in __call__(self, s) 182return value: a date2num float 183 -- 184 return date2num(datetime.datetime(*time.strptime(s, self.fmt) [:6])) 185 186 def datestr2num(d): /usr/lib/python2.4/_strptime.py in strptime(data_string, format) 291 found = format_regex.match(data_string) 292 if not found: -- 293 raise ValueError(time data did not match format: data=%s fmt=%s % 294 (data_string, format)) 295 if len(data_string) != found.end(): ValueError: time data did not match format: data=15/01/2007 fmt=%d/%m/%Y I didn't understood the problem, anyone can help me ? - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Printing gif images to file with matplotlib
You can just pass a path to savefig, e.g.: savefig(/home/me/test.png) (The format is automatically determined from the extension). If you want to know which formats are supported by which backends, you can have a look at FILETYPES in the source tree here: http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/FILETYPES?view=markup Many of the examples for matplotlib have savefig, but the line is usually commented out. Just remove the '#' and you have lots of examples. Cheers, Mike Takashi Yamamoto wrote: Hi, I have recently come across Matplotlib and I am very impressed with its capabilities. I am new to both Matplotlib and Python, although I have several years experience with C++ and a few other languages *(including modelling with MatLab). I have successfully embedded Python in a C++ application, and can run python scripts from my C++ application. However, I have found displaying graphs in a GUI fraught with (insurmountable?) problems and I have decided to NOT use a GUI at all, but rather, to save plots as image, to file (e.g. png, gif or jpeg). Can anyone give me a simple example script that shows how I may use *savefig*(), to save a plot as an image (any of the above formats), to file? Thanks Connect to the next generation of MSN Messenger Get it now! http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-ussource=wlmailtagline - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] using strpdate2num in load
On Dec 11, 2007 6:00 AM, Emmanuel [EMAIL PROTECTED] wrote: Hi, I've a little problem with date conversion. I have a csv file which looks like : Data,Valor 15/01/2007, 6,700012000 12/01/2007, 6,659903000 11/01/2007, 6,701586000 I try to get date using function strpdate2num in load doing this : Try stripping the double quote characters from you file. JDH - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Repeated calls to set_text using TeX formatting results in RuntimeError
I believe this is a known bug with 0.90.1. Are you able to run 0.91.1? Cheers, Mike [EMAIL PROTECTED] wrote: I'm doing a parameter fitting exercise, and plotting the progress as I do so. I have found that repeated calls to set_text() on a text object will result in an error opening a font file iff the text uses TeX formatting. (I am not using the experimental usetex feature). I speculate that matplotlib is opening the font file anew with each call to set_text and never closing it, resulting ultimately in having too many files open. Here is a brief program to reproduce this behavior (WinXP, Py2.5, matplotlib 0.90.1): from pylab import figure, axes, draw, ion from numpy import array, cos, abs ion() fig=figure() axs=axes() x=array(range(100))/10.0 cosPlot=axs.plot( x, cos(x)**2, 'r' ) powText = axs.text(0.9,0.02,r'$\alpha=$', horizontalalignment='left',verticalalignment='bottom', transform = axs.transAxes) draw() for alpha in array(range(10,400))/100.0: axs.lines[-1].set_ydata( abs(cos(x))**alpha) powText.set_text(r'$\alpha=%.4g$'%alpha) print alpha draw() Traceback (most recent call last): File delme.py, line 16, in module File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matplotlib\pylab.py, line 754, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matplotlib\backends\backend_tkagg.py, line 154, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matplotlib\backends\backend_agg.py, line 392, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matplotlib\figure.py, line 601, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matplotlib\axes.py, line 1286, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matplotlib\text.py, line 410, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matplotlib\text.py, line 255, in _get_layout File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matplotlib\backends\backend_agg.py, line 246, in get_text_width_height File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matplotlib\mathtext.py, line 1569, in __call__ File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matplotlib\mathtext.py, line 578, in __init__ RuntimeError: Could not open facefile c:\Python25\lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matplotlib\mpl-data\fonts\ttf\cmtt10.ttf; Cannot_Open_Resource - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Repeated calls to set_text using TeX formatting results in RuntimeError
I'm doing a parameter fitting exercise, and plotting the progress as I do so. I have found that repeated calls to set_text() on a text object will result in an error opening a font file iff the text uses TeX formatting. (I am not using the experimental usetex feature). I speculate that matplotlib is opening the font file anew with each call to set_text and never closing it, resulting ultimately in having too many files open. Here is a brief program to reproduce this behavior (WinXP, Py2.5, matplotlib 0.90.1): from pylab import figure, axes, draw, ion from numpy import array, cos, abs ion() fig=figure() axs=axes() x=array(range(100))/10.0 cosPlot=axs.plot( x, cos(x)**2, 'r' ) powText = axs.text(0.9,0.02,r'$\alpha=$', horizontalalignment='left',verticalalignment='bottom', transform = axs.transAxes) draw() for alpha in array(range(10,400))/100.0: axs.lines[-1].set_ydata( abs(cos(x))**alpha) powText.set_text(r'$\alpha=%.4g$'%alpha) print alpha draw() Traceback (most recent call last): File delme.py, line 16, in module File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\pylab.py, line 754, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\backends\backend_tkagg.py, line 154, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\backends\backend_agg.py, line 392, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\figure.py, line 601, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\axes.py, line 1286, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\text.py, line 410, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\text.py, line 255, in _get_layout File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\backends\backend_agg.py, line 246, in get_text_width_height File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\mathtext.py, line 1569, in __call__ File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\mathtext.py, line 578, in __init__ RuntimeError: Could not open facefile c:\Python25\lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matplo tlib\mpl-data\fonts\ttf\cmtt10.ttf; Cannot_Open_Resource This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system and destroy any copies thereof. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Repeated calls to set_text using TeX formatting results in RuntimeError
On Dec 11, 2007 8:17 AM, Michael Droettboom [EMAIL PROTECTED] wrote: I believe this is a known bug with 0.90.1. Are you able to run 0.91.1? If I am reading this right, according to the svn log, you fixed this in r4633 | mdboom | 2007-12-05 14:28:28 -0600 (Wed, 05 Dec 2007) | 2 lines Fix bug where font files were opened many more times than they need to be. and 0.91.1 was released at r4517. So this fix may not be out until the 0.91.2 point release. Or were you referring to a different fix? JDH - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Repeated calls to set_text using TeX formatting results in RuntimeError
This bug is that many font files were being opened than needed, but they were still all getting closed. Much earlier, someone else fixed a bug where they weren't getting closed at all. http://sourceforge.net/tracker/index.php?func=detailaid=1695171group_id=80706atid=560720 http://sourceforge.net/tracker/index.php?func=detailaid=1715662group_id=80706atid=560720 Cheers, Mike John Hunter wrote: On Dec 11, 2007 8:17 AM, Michael Droettboom [EMAIL PROTECTED] wrote: I believe this is a known bug with 0.90.1. Are you able to run 0.91.1? If I am reading this right, according to the svn log, you fixed this in r4633 | mdboom | 2007-12-05 14:28:28 -0600 (Wed, 05 Dec 2007) | 2 lines Fix bug where font files were opened many more times than they need to be. and 0.91.1 was released at r4517. So this fix may not be out until the 0.91.2 point release. Or were you referring to a different fix? JDH -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Repeated calls to set_text using TeX formatting results in RuntimeError
I believe this is a known bug with 0.90.1. Are you able to run 0.91.1? I just upgraded and checked -- the bug still exists in 0.91.1. I'm afraid I don't know whether it has been fixed by r4633 or not. Best, Brian [EMAIL PROTECTED] wrote: I'm doing a parameter fitting exercise, and plotting the progress as I do so. I have found that repeated calls to set_text() on a text object will result in an error opening a font file iff the text uses TeX formatting. (I am not using the experimental usetex feature). I speculate that matplotlib is opening the font file anew with each call to set_text and never closing it, resulting ultimately in having too many files open. Here is a brief program to reproduce this behavior (WinXP, Py2.5, matplotlib 0.90.1): from pylab import figure, axes, draw, ion from numpy import array, cos, abs ion() fig=figure() axs=axes() x=array(range(100))/10.0 cosPlot=axs.plot( x, cos(x)**2, 'r' ) powText = axs.text(0.9,0.02,r'$\alpha=$', horizontalalignment='left',verticalalignment='bottom', transform = axs.transAxes) draw() for alpha in array(range(10,400))/100.0: axs.lines[-1].set_ydata( abs(cos(x))**alpha) powText.set_text(r'$\alpha=%.4g$'%alpha) print alpha draw() Traceback (most recent call last): File delme.py, line 16, in module File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\pylab.py, line 754, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\backends\backend_tkagg.py, line 154, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\backends\backend_agg.py, line 392, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\figure.py, line 601, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\axes.py, line 1286, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\text.py, line 410, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\text.py, line 255, in _get_layout File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\backends\backend_agg.py, line 246, in get_text_width_height File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\mathtext.py, line 1569, in __call__ File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\mathtext.py, line 578, in __init__ RuntimeError: Could not open facefile c:\Python25\lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matplo tlib\mpl-data\fonts\ttf\cmtt10.ttf; Cannot_Open_Resource -- -- -- --- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php -- -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system and destroy any copies thereof. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Repeated calls to set_text using TeX formatting results in RuntimeError
The patch for r4633 is pretty simple, so you could test it without needing to check out from SVN or build your own matplotlib etc. Open the file font_manager.py, which should live in %PYTHONPATH%/Lib/site-packages/matplotlib. Around line 681, you'll find the function: def __hash__(self): return hash(repr(self.__props)) Change it to: def __hash__(self): return hash(repr(self.__props.__dict__)) (Obviously, back up the file first...) Then try your script again. If that doesn't work, I'll have to fire up Windows some time to have a look -- I'm not able to reproduce this bug on Linux. Cheers, Mike [EMAIL PROTECTED] wrote: I believe this is a known bug with 0.90.1. Are you able to run 0.91.1? I just upgraded and checked -- the bug still exists in 0.91.1. I'm afraid I don't know whether it has been fixed by r4633 or not. Best, Brian [EMAIL PROTECTED] wrote: I'm doing a parameter fitting exercise, and plotting the progress as I do so. I have found that repeated calls to set_text() on a text object will result in an error opening a font file iff the text uses TeX formatting. (I am not using the experimental usetex feature). I speculate that matplotlib is opening the font file anew with each call to set_text and never closing it, resulting ultimately in having too many files open. Here is a brief program to reproduce this behavior (WinXP, Py2.5, matplotlib 0.90.1): from pylab import figure, axes, draw, ion from numpy import array, cos, abs ion() fig=figure() axs=axes() x=array(range(100))/10.0 cosPlot=axs.plot( x, cos(x)**2, 'r' ) powText = axs.text(0.9,0.02,r'$\alpha=$', horizontalalignment='left',verticalalignment='bottom', transform = axs.transAxes) draw() for alpha in array(range(10,400))/100.0: axs.lines[-1].set_ydata( abs(cos(x))**alpha) powText.set_text(r'$\alpha=%.4g$'%alpha) print alpha draw() Traceback (most recent call last): File delme.py, line 16, in module File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\pylab.py, line 754, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\backends\backend_tkagg.py, line 154, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\backends\backend_agg.py, line 392, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\figure.py, line 601, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\axes.py, line 1286, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\text.py, line 410, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\text.py, line 255, in _get_layout File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\backends\backend_agg.py, line 246, in get_text_width_height File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\mathtext.py, line 1569, in __call__ File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl otlib\mathtext.py, line 578, in __init__ RuntimeError: Could not open facefile c:\Python25\lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matplo tlib\mpl-data\fonts\ttf\cmtt10.ttf; Cannot_Open_Resource -- -- -- --- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php -- -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system and destroy any copies thereof. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy
Re: [Matplotlib-users] Repeated calls to set_text using TeX formatting results in RuntimeError
Michael et al. The r4633 patch fixes the problem indeed. Thanks for your help!! Brian -Original Message- From: Michael Droettboom [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 11, 2007 10:03 AM To: Boonstra, Brian Cc: matplotlib-users@lists.sourceforge.net Subject: Re: [Matplotlib-users] Repeated calls to set_text using TeX formatting results in RuntimeError The patch for r4633 is pretty simple, so you could test it without needing to check out from SVN or build your own matplotlib etc. Open the file font_manager.py, which should live in %PYTHONPATH%/Lib/site-packages/matplotlib. Around line 681, you'll find the function: def __hash__(self): return hash(repr(self.__props)) Change it to: def __hash__(self): return hash(repr(self.__props.__dict__)) (Obviously, back up the file first...) Then try your script again. If that doesn't work, I'll have to fire up Windows some time to have a look -- I'm not able to reproduce this bug on Linux. Cheers, Mike [EMAIL PROTECTED] wrote: I believe this is a known bug with 0.90.1. Are you able to run 0.91.1? I just upgraded and checked -- the bug still exists in 0.91.1. I'm afraid I don't know whether it has been fixed by r4633 or not. Best, Brian [EMAIL PROTECTED] wrote: I'm doing a parameter fitting exercise, and plotting the progress as I do so. I have found that repeated calls to set_text() on a text object will result in an error opening a font file iff the text uses TeX formatting. (I am not using the experimental usetex feature). I speculate that matplotlib is opening the font file anew with each call to set_text and never closing it, resulting ultimately in having too many files open. Here is a brief program to reproduce this behavior (WinXP, Py2.5, matplotlib 0.90.1): from pylab import figure, axes, draw, ion from numpy import array, cos, abs ion() fig=figure() axs=axes() x=array(range(100))/10.0 cosPlot=axs.plot( x, cos(x)**2, 'r' ) powText = axs.text(0.9,0.02,r'$\alpha=$', horizontalalignment='left',verticalalignment='bottom', transform = axs.transAxes) draw() for alpha in array(range(10,400))/100.0: axs.lines[-1].set_ydata( abs(cos(x))**alpha) powText.set_text(r'$\alpha=%.4g$'%alpha) print alpha draw() Traceback (most recent call last): File delme.py, line 16, in module File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matp l otlib\pylab.py, line 754, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matp l otlib\backends\backend_tkagg.py, line 154, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matp l otlib\backends\backend_agg.py, line 392, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matp l otlib\figure.py, line 601, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matp l otlib\axes.py, line 1286, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matp l otlib\text.py, line 410, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matp l otlib\text.py, line 255, in _get_layout File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matp l otlib\backends\backend_agg.py, line 246, in get_text_width_height File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matp l otlib\mathtext.py, line 1569, in __call__ File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matp l otlib\mathtext.py, line 578, in __init__ RuntimeError: Could not open facefile c:\Python25\lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl o tlib\mpl-data\fonts\ttf\cmtt10.ttf; Cannot_Open_Resource - - -- - - --- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php - - -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system and destroy any
Re: [Matplotlib-users] Repeated calls to set_text using TeX formatting results in RuntimeError
Great. The forthcoming 0.91.2 release sounds like it will be very important to Windows users. Apologies for introducing this bug in the first place! Cheers, Mike [EMAIL PROTECTED] wrote: Michael et al. The r4633 patch fixes the problem indeed. Thanks for your help!! Brian -Original Message- From: Michael Droettboom [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 11, 2007 10:03 AM To: Boonstra, Brian Cc: matplotlib-users@lists.sourceforge.net Subject: Re: [Matplotlib-users] Repeated calls to set_text using TeX formatting results in RuntimeError The patch for r4633 is pretty simple, so you could test it without needing to check out from SVN or build your own matplotlib etc. Open the file font_manager.py, which should live in %PYTHONPATH%/Lib/site-packages/matplotlib. Around line 681, you'll find the function: def __hash__(self): return hash(repr(self.__props)) Change it to: def __hash__(self): return hash(repr(self.__props.__dict__)) (Obviously, back up the file first...) Then try your script again. If that doesn't work, I'll have to fire up Windows some time to have a look -- I'm not able to reproduce this bug on Linux. Cheers, Mike [EMAIL PROTECTED] wrote: I believe this is a known bug with 0.90.1. Are you able to run 0.91.1? I just upgraded and checked -- the bug still exists in 0.91.1. I'm afraid I don't know whether it has been fixed by r4633 or not. Best, Brian [EMAIL PROTECTED] wrote: I'm doing a parameter fitting exercise, and plotting the progress as I do so. I have found that repeated calls to set_text() on a text object will result in an error opening a font file iff the text uses TeX formatting. (I am not using the experimental usetex feature). I speculate that matplotlib is opening the font file anew with each call to set_text and never closing it, resulting ultimately in having too many files open. Here is a brief program to reproduce this behavior (WinXP, Py2.5, matplotlib 0.90.1): from pylab import figure, axes, draw, ion from numpy import array, cos, abs ion() fig=figure() axs=axes() x=array(range(100))/10.0 cosPlot=axs.plot( x, cos(x)**2, 'r' ) powText = axs.text(0.9,0.02,r'$\alpha=$', horizontalalignment='left',verticalalignment='bottom', transform = axs.transAxes) draw() for alpha in array(range(10,400))/100.0: axs.lines[-1].set_ydata( abs(cos(x))**alpha) powText.set_text(r'$\alpha=%.4g$'%alpha) print alpha draw() Traceback (most recent call last): File delme.py, line 16, in module File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matp l otlib\pylab.py, line 754, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matp l otlib\backends\backend_tkagg.py, line 154, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matp l otlib\backends\backend_agg.py, line 392, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matp l otlib\figure.py, line 601, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matp l otlib\axes.py, line 1286, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matp l otlib\text.py, line 410, in draw File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matp l otlib\text.py, line 255, in _get_layout File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matp l otlib\backends\backend_agg.py, line 246, in get_text_width_height File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matp l otlib\mathtext.py, line 1569, in __call__ File C:\Python25\Lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matp l otlib\mathtext.py, line 578, in __init__ RuntimeError: Could not open facefile c:\Python25\lib\site-packages\matplotlib-0.90.1-py2.5-win32.egg\matpl o tlib\mpl-data\fonts\ttf\cmtt10.ttf; Cannot_Open_Resource - - -- - - --- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php - - -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA This message contains confidential information and is intended only for the individual named. If you are not the named
[Matplotlib-users] re ndered objects (esp. SVG)
[Fairly new at matplotlib, but very happy with it so far] Is it possible to retrieve images rendered by one of the backends as an object, rather than just saving to a file? Specifically, I need to render graphs to SVG code, that I can turn into a DOM object for further manipulation. I can save to a temp file and immediately reload it into a DOM, but that is cumbersome in a single program. The only place I can see to generate rendered output is savefig(). There is a reference in the documentation to using a file-like object with the Cairo backend. Is that the only possibility? If so, any ideas on a workaround other than temp files? -- View this message in context: http://www.nabble.com/rendered-objects-%28esp.-SVG%29-tf4952354.html#a14180802 Sent from the matplotlib - users mailing list archive at Nabble.com. - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Scientific visualisation techniques
I am part of a team trying to create interactive GUI scientific visualisations and would like some advice regarding the best way to proceed. We are trying to output mathematical functions (Fourier transforms, ray tracing etc.) in graphical form and have been very impressed with the ease Matplotlib can do this. However, all attempts to control or modify input to Matplotlib from a GUI (Tkinter, Wx, Jython, PyGTK etc.) have proved fruitless due to seeming incompatibility between these modules, particularly when one distributes any finished product to another platform. I am an experienced Java programmer who needs the portability and free technologies provided by Java (or Python) to distribute our applications and would like to know of the best way to mesh Matplotlib to a GUI creating system. We have experimented with the GUI creation possibilities of Matplotlib itself but these are inadequate for our needs. Does anyone know of (or has examples of) Matplotlib applications controlled by a GUI or must I return to my Java roots where I can easily solve all GUI problems but do not have access to a powerful maths library such as Matplotlib. Thanks adam -- View this message in context: http://www.nabble.com/Scientific-visualisation-techniques-tf4963066.html#a14215824 Sent from the matplotlib - users mailing list archive at Nabble.com. - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] problems with 0.91.1 and python 2.5.1
Hello i' am an newbie in matplotlib and python! I've installed python 2.5.1 + numpy 1.0.4 + numarray 1.5.2 but have many problems ! I've written an easy plot script import matplotlib import pylab from pylab import arange,sin,pi,plot,xlabel,ylabel,title,grid,show,axis ymax = max([1,4,9,16,12,5,7,13,7,1,33]) ymin = min([1,-4,9,16,12,5,7,13,7,1,33]) print 'ymax = %s' % ymax print 'ymin = %s' % ymin plot([1,2,3,4,5,6,7,8,9,10,11], [1,4,9,16,12,5,7,13,7,1,33], 'ro') axis([0, 15, ymin-5, ymax+5]) xlabel('time (s)') ylabel('voltage (mV)') title('About as simple as it gets, folks') grid(True) show() -- AND i get some problems D:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\numerix\__init__.py:65: DeprecationWarning: numarray use as a numerix backed for matplotlib is deprecated DeprecationWarning, stacklevel=1) Traceback (most recent call last): File D:\workspace-py\GDOParser\PlotTest.py, line 12, in module plot([1,2,3,4], [1,4,9,16], 'ro') File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\pyplot.py, line 1775, in plot b = ishold() File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\pyplot.py, line 340, in ishold return gca().ishold() File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\pyplot.py, line 433, in gca ax = gcf().gca(**kwargs) File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\figure.py, line 722, in gca return self.add_subplot(111, **kwargs) File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\figure.py, line 542, in add_subplot a = Subplot(self, *args, **kwargs) File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\axes.py, line 5561, in __init__ self.figW, self.figH], **kwargs) File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\axes.py, line 507, in __init__ self._init_axis() File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\axes.py, line 545, in _init_axis self.xaxis = maxis.XAxis(self) File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\axis.py, line 518, in __init__ self.cla() File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\axis.py, line 553, in cla self.majorTicks.extend([self._get_tick(major=True) for i in range(1)]) File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\axis.py, line 1033, in _get_tick return XTick(self.axes, 0, '', major=major) File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\axis.py, line 96, in __init__ self.tick1line = self._get_tick1line(loc) File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\axis.py, line 285, in _get_tick1line markersize=self._size, File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\lines.py, line 284, in __init__ self.set_data(xdata, ydata) File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\lines.py, line 405, in set_data self.recache() File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\lines.py, line 410, in recache x = ma.asarray(self.convert_xunits(self._xorig), float) File D:\Program Files\Python-2.5.1\Lib\site-packages\numarray\ma\MA.py, line 2164, in asarray return array(data, typecode=typecode, copy=0) File D:\Program Files\Python-2.5.1\Lib\site-packages\numarray\ma\MA.py, line 628, in __init__ c = Numeric.array(data, tc, savespace=ss) File D:\Program Files\Python-2.5.1\Lib\site-packages\numarray\numarraycore.py, line 334, in array type=_nt._typeFromKeywords(type,typecode,dtype) File d:\Program Files\Python-2.5.1\Lib\site-packages\numarray\numerictypes.py, line 474, in _typeFromKeywords return getType(typecode) File d:\Program Files\Python-2.5.1\Lib\site-packages\numarray\numerictypes.py, line 450, in getType raise TypeError(Not a numeric type) TypeError: Not a numeric type Has anyone an idea? Thanks Thorsten -- View this message in context: http://www.nabble.com/problems-with-0.91.1-and-python-2.5.1-tp14269662p14269662.html Sent from the matplotlib - users mailing list archive at Nabble.com. - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Scientific visualisation techniques
On Dec 7, 2007 10:38 AM, adamski246 [EMAIL PROTECTED] wrote: Does anyone know of (or has examples of) Matplotlib applications controlled by a GUI or must I return to my Java roots where I can easily solve all GUI problems but do not have access to a powerful maths library such as Matplotlib. matplotlib can be easily embedded in tk, gtk, wx, qt or fltk. See the API FAQ at http://matplotlib.sf.net/faq.html#OO and the embedding_in_*.py examples at http://matplotlib.sf.net/examples - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to show matplotlib.image ?
On Dec 5, 2007, at 11:58 AM, Christopher Barker wrote: or use wxmpl: http://agni.phys.iit.edu/~kmcivor/wxmpl/ By the way, couldn't that be distributed with Matplotlib? Maybe in toolkits, if not the main distro. I'd be all for having wxmpl distributed as part of the matplotlib toolkits. I had originally hoped to merge it into the main distribution after unifying the event handling so that matplotlib events worked robustly, but I don't see myself finding the time to work on it any time soon. Ken - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] problems with 0.91.1 and python 2.5.1
I think the problem might be related to using numarray and not numpy. matplotlib is not heavily tested (if at all) on anything but numpy anymore. See this from your output log: D:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\numerix\__init__.py:65: DeprecationWarning: numarray use as a numerix backed for matplotlib is deprecated DeprecationWarning, stacklevel=1) Indeed, using float as a type specifier works with numpy but not with numarray. Try setting your numerix setting to numpy in your matplotlibrc file. If there are good reasons that you need to keep using numarray (for compatibility with your own code for instance), please mention that on this list -- there may be workarounds. Cheers, Mike Thorsten.G wrote: Hello i' am an newbie in matplotlib and python! I've installed python 2.5.1 + numpy 1.0.4 + numarray 1.5.2 but have many problems ! I've written an easy plot script import matplotlib import pylab from pylab import arange,sin,pi,plot,xlabel,ylabel,title,grid,show,axis ymax = max([1,4,9,16,12,5,7,13,7,1,33]) ymin = min([1,-4,9,16,12,5,7,13,7,1,33]) print 'ymax = %s' % ymax print 'ymin = %s' % ymin plot([1,2,3,4,5,6,7,8,9,10,11], [1,4,9,16,12,5,7,13,7,1,33], 'ro') axis([0, 15, ymin-5, ymax+5]) xlabel('time (s)') ylabel('voltage (mV)') title('About as simple as it gets, folks') grid(True) show() -- AND i get some problems D:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\numerix\__init__.py:65: DeprecationWarning: numarray use as a numerix backed for matplotlib is deprecated DeprecationWarning, stacklevel=1) Traceback (most recent call last): File D:\workspace-py\GDOParser\PlotTest.py, line 12, in module plot([1,2,3,4], [1,4,9,16], 'ro') File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\pyplot.py, line 1775, in plot b = ishold() File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\pyplot.py, line 340, in ishold return gca().ishold() File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\pyplot.py, line 433, in gca ax = gcf().gca(**kwargs) File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\figure.py, line 722, in gca return self.add_subplot(111, **kwargs) File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\figure.py, line 542, in add_subplot a = Subplot(self, *args, **kwargs) File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\axes.py, line 5561, in __init__ self.figW, self.figH], **kwargs) File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\axes.py, line 507, in __init__ self._init_axis() File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\axes.py, line 545, in _init_axis self.xaxis = maxis.XAxis(self) File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\axis.py, line 518, in __init__ self.cla() File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\axis.py, line 553, in cla self.majorTicks.extend([self._get_tick(major=True) for i in range(1)]) File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\axis.py, line 1033, in _get_tick return XTick(self.axes, 0, '', major=major) File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\axis.py, line 96, in __init__ self.tick1line = self._get_tick1line(loc) File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\axis.py, line 285, in _get_tick1line markersize=self._size, File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\lines.py, line 284, in __init__ self.set_data(xdata, ydata) File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\lines.py, line 405, in set_data self.recache() File d:\Program Files\Python-2.5.1\Lib\site-packages\matplotlib\lines.py, line 410, in recache x = ma.asarray(self.convert_xunits(self._xorig), float) File D:\Program Files\Python-2.5.1\Lib\site-packages\numarray\ma\MA.py, line 2164, in asarray return array(data, typecode=typecode, copy=0) File D:\Program Files\Python-2.5.1\Lib\site-packages\numarray\ma\MA.py, line 628, in __init__ c = Numeric.array(data, tc, savespace=ss) File D:\Program Files\Python-2.5.1\Lib\site-packages\numarray\numarraycore.py, line 334, in array type=_nt._typeFromKeywords(type,typecode,dtype) File d:\Program Files\Python-2.5.1\Lib\site-packages\numarray\numerictypes.py, line 474, in _typeFromKeywords return getType(typecode) File d:\Program Files\Python-2.5.1\Lib\site-packages\numarray\numerictypes.py, line 450, in getType raise TypeError(Not a numeric type) TypeError: Not a numeric type Has anyone an idea? Thanks Thorsten -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA - SF.Net email is sponsored
Re: [Matplotlib-users] re ndered objects (esp. SVG)
[I only seem to be getting this message from the list today, despite the timestamp of 2007-12-05. Sorry for the delay.] As of matplotlib 0.91.1, savefig() supports saving to a file-like object for most backends (excluding Gtk and Wx). You can pass in a StringIO object to savefig for instance, and then pass its content to the XML parser of your choice. (There is no way to get DOM objects directly, since the SVG backend actually writes the XML content directly as a stream of bytes). You can specify SVG as your output by either setting the backend appropriately or passing a format kwarg to savfig, e.g. savefig(fileobj, format=svg) Cheers, Mike bplewe wrote: [Fairly new at matplotlib, but very happy with it so far] Is it possible to retrieve images rendered by one of the backends as an object, rather than just saving to a file? Specifically, I need to render graphs to SVG code, that I can turn into a DOM object for further manipulation. I can save to a temp file and immediately reload it into a DOM, but that is cumbersome in a single program. The only place I can see to generate rendered output is savefig(). There is a reference in the documentation to using a file-like object with the Cairo backend. Is that the only possibility? If so, any ideas on a workaround other than temp files? -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Scientific visualisation techniques
You say you tried wx but don't mention wxmpl explicitly - did you try wxmpl (http://agni.phys.iit.edu/~kmcivor/wxmpl/)? DG adamski246 wrote: I am part of a team trying to create interactive GUI scientific visualisations and would like some advice regarding the best way to proceed. We are trying to output mathematical functions (Fourier transforms, ray tracing etc.) in graphical form and have been very impressed with the ease Matplotlib can do this. However, all attempts to control or modify input to Matplotlib from a GUI (Tkinter, Wx, Jython, PyGTK etc.) have proved fruitless due to seeming incompatibility between these modules, particularly when one distributes any finished product to another platform. I am an experienced Java programmer who needs the portability and free technologies provided by Java (or Python) to distribute our applications and would like to know of the best way to mesh Matplotlib to a GUI creating system. We have experimented with the GUI creation possibilities of Matplotlib itself but these are inadequate for our needs. Does anyone know of (or has examples of) Matplotlib applications controlled by a GUI or must I return to my Java roots where I can easily solve all GUI problems but do not have access to a powerful maths library such as Matplotlib. Thanks adam - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Scientific visualisation techniques
David.Goldsmith wrote: You say you tried wx but don't mention wxmpl explicitly - did you try wxmpl (http://agni.phys.iit.edu/~kmcivor/wxmpl/)? good choice -- the other is to follow the embedded_in_*** examples -- where are they? A quick googling didn't find them! all attempts to control or modify input to Matplotlib from a GUI (Tkinter, Wx, Jython, PyGTK etc.) have proved fruitless due to seeming incompatibility between these modules, I'm guessing that you're using the pylab interface -- pylab manages the GUI for you -- which is great if you're doing simple interactive plotting, but will not work if you are embedding MPL in a gui -- you need to use the OO interface instead -- see the embedded_in_*** examples. particularly when one distributes any finished product to another platform. This is no harder than with JAVA -- easier I think -- you can completely control the environment if you want -- see py2exe, pyInstaller, py2app, etc. I return to my Java roots where I can easily solve all GUI problems Once you get the hang of Python, I think you'll find that you can solve your GUI problems even more easily! I'm partial to wxPython, but pyQT and pyGTK have their strengths also. As a JAVA coder, I recommend you read: http://dirtsimple.org/2004/12/python-is-not-java.html -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/ORR(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] installation problem/crash
I am trying to help a student get started with Python/Scipy/Numpy/Matplotlib in windows. On one of his machines, everything seems to install correctly, we can call figure(1) without a problem, and plotting is fine until we try the show() command. Then python crashes without much in the way of useful information. His laptop is completely fine. We have downloaded a current rc file and set the backend to TkAgg. Any thoughts? How do we get more info to track down the problem? Thanks, Ryan - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] re ndered objects (esp. SVG)
I should add that in 0.91.1, you'll be hit by this bug: http://sourceforge.net/mailarchive/message.php?msg_name=475ED00A.400%40stsci.edu You can wait for 0.91.2, or patch your cbook.py as suggested by Brandon in the above thread. Cheers, Mike Michael Droettboom wrote: [I only seem to be getting this message from the list today, despite the timestamp of 2007-12-05. Sorry for the delay.] As of matplotlib 0.91.1, savefig() supports saving to a file-like object for most backends (excluding Gtk and Wx). You can pass in a StringIO object to savefig for instance, and then pass its content to the XML parser of your choice. (There is no way to get DOM objects directly, since the SVG backend actually writes the XML content directly as a stream of bytes). You can specify SVG as your output by either setting the backend appropriately or passing a format kwarg to savfig, e.g. savefig(fileobj, format=svg) Cheers, Mike bplewe wrote: [Fairly new at matplotlib, but very happy with it so far] Is it possible to retrieve images rendered by one of the backends as an object, rather than just saving to a file? Specifically, I need to render graphs to SVG code, that I can turn into a DOM object for further manipulation. I can save to a temp file and immediately reload it into a DOM, but that is cumbersome in a single program. The only place I can see to generate rendered output is savefig(). There is a reference in the documentation to using a file-like object with the Cairo backend. Is that the only possibility? If so, any ideas on a workaround other than temp files? -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] installation problem/crash
On Dec 11, 2007 1:01 PM, Ryan Krauss [EMAIL PROTECTED] wrote: I am trying to help a student get started with Python/Scipy/Numpy/Matplotlib in windows. On one of his machines, everything seems to install correctly, we can call figure(1) without a problem, and plotting is fine until we try the show() command. Then python crashes without much in the way of useful information. His laptop is completely fine. We have downloaded a current rc file and set the backend to TkAgg. Any thoughts? First try import numpy numpy.test() there is a numpy problem on windows that affects older machines. If that works, create a simple test file that generates a plot and calls savefig and run it with python myscript.py --verbose-debug-annoying try different backends by adding -dPS or -dAgg to the verbose flag from the command line and see which backends crash and report back with the verbose output JDH - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] installation problem/crash
On Dec 11, 2007 12:01 PM, Ryan Krauss [EMAIL PROTECTED] wrote: I am trying to help a student get started with Python/Scipy/Numpy/Matplotlib in windows. On one of his machines, everything seems to install correctly, we can call figure(1) without a problem, and plotting is fine until we try the show() command. Then python crashes without much in the way of useful information. His laptop is completely fine. We have downloaded a current rc file and set the backend to TkAgg. Any thoughts? How do we get more info to track down the problem? Go to the windows information screens and fetch out some CPU details. If it's a Pentium III, chances are the SSE2 instructions in the latest numpy binary are the culprit. If it's a newer chip, we'll need to dig deeper. Cheers, f - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] installation problem/crash
Pretty sure it's a newer chip, but I will find out. On Dec 11, 2007 2:06 PM, Fernando Perez [EMAIL PROTECTED] wrote: On Dec 11, 2007 12:01 PM, Ryan Krauss [EMAIL PROTECTED] wrote: I am trying to help a student get started with Python/Scipy/Numpy/Matplotlib in windows. On one of his machines, everything seems to install correctly, we can call figure(1) without a problem, and plotting is fine until we try the show() command. Then python crashes without much in the way of useful information. His laptop is completely fine. We have downloaded a current rc file and set the backend to TkAgg. Any thoughts? How do we get more info to track down the problem? Go to the windows information screens and fetch out some CPU details. If it's a Pentium III, chances are the SSE2 instructions in the latest numpy binary are the culprit. If it's a newer chip, we'll need to dig deeper. Cheers, f - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] can matplotlib do this?
Matplotlib users, I looking to tap your wealth of ideas and experience to help solve a problem I'm working on. The problem: I have a series of 2d scalar arrays representing a fixed width/height lon/lat box centered on an arbitrary lon/lat. I need to average these composites on a common basis that accommodates the scale changes due to latitude, preferably by shifting everything to a common central lon/lat (a polar/radial distance basis would work too). I want a plot of the end result too and I'm like to do everything with matplotlib and python so that it folds into the rest of my program. Something similar can be seen at http://www.atmos.washington.edu/~robwood/topic_cyclones.htm I've been looking at transform_scalar from basemap but I'm not quite sure this is what I should use. If anyone can offer a solution, a point in the right direction, or just wave me off this path I'd be most appreciative. Mike - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] installation problem/crash
Fernando was right on. Here is his response to me: Laptop - Ok Windows XP Professional, Service Pack 2 AMD Athlon 64 3400+ (ClawHammer) 1.67 GHz, 768 MB of RAM Chipset: SiS 755/755FX Southbridge: SiS LPC Bridge Instructions: MMX (+), 3DNow! (+), SSE, SSE2, x86-64 Machine 1 - Crashes Windows XP Professional, Service Pack 2 AMD Athlon XP 2000+ (Thoroughbred) 1.67 GHz, 768 MB of RAM ASUS A7V8X-X motherboard Chipset: VIA KT400 (VT8377) Southbridge: VIA VT8235 Instructions: MMX (+), 3DNow! (+), SSE Machine 2 - Crashes Windows XP Professional, Service Pack 2 AMD Athlon XP 2600+ (Barton) 1.92 GHz, 2.0 GB of RAM ASUS A7V880 motherboard Chipset: VIA KT880 Southbridge: VIA VT8237 Instructions: MMX (+), 3DNow! (+), SSE I ran the following statements on both machines which caused it to crash: import numpy numpy.test() Here is the output: Numpy is installed in C:\Python25\lib\site-packages\numpy Numpy version 1.0.4 Python version 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Int el)] Found 10/10 tests for numpy.core.defmatrix Found 36/36 tests for numpy.core.ma Found 223/223 tests for numpy.core.multiarray Found 65/65 tests for numpy.core.numeric Found 31/31 tests for numpy.core.numerictypes Found 12/12 tests for numpy.core.records Found 6/6 tests for numpy.core.scalarmath Found 14/14 tests for numpy.core.umath Found 4/4 tests for numpy.ctypeslib Found 5/5 tests for numpy.distutils.misc_util Found 1/1 tests for numpy.fft.fftpack Found 3/3 tests for numpy.fft.helper Found 9/9 tests for numpy.lib.arraysetops Found 46/46 tests for numpy.lib.function_base Found 5/5 tests for numpy.lib.getlimits Found 4/4 tests for numpy.lib.index_tricks Found 3/3 tests for numpy.lib.polynomial Found 49/49 tests for numpy.lib.shape_base Found 15/15 tests for numpy.lib.twodim_base Found 43/43 tests for numpy.lib.type_check Found 1/1 tests for numpy.lib.ufunclike Found 40/40 tests for numpy.linalg Found 2/2 tests for numpy.random Found 0/0 tests for __main__ . Sounds like the problem is the fact that my desktop computers do not support SSE2 instructions which are in the latest numpy binaries. This also explains why it works fine on the laptop which does support SSE2. I piggy-backed onto an existing thread on the numpy list (is that bad listserve etiquette? - probably: I now have the same question on two lists and I tried to high jack a thread.). Unless someone has a better idea, I will try and build from source for him. But my windows building skills are not what they should be. Ryan On Dec 11, 2007 2:06 PM, Fernando Perez [EMAIL PROTECTED] wrote: On Dec 11, 2007 12:01 PM, Ryan Krauss [EMAIL PROTECTED] wrote: I am trying to help a student get started with Python/Scipy/Numpy/Matplotlib in windows. On one of his machines, everything seems to install correctly, we can call figure(1) without a problem, and plotting is fine until we try the show() command. Then python crashes without much in the way of useful information. His laptop is completely fine. We have downloaded a current rc file and set the backend to TkAgg. Any thoughts? How do we get more info to track down the problem? Go to the windows information screens and fetch out some CPU details. If it's a Pentium III, chances are the SSE2 instructions in the latest numpy binary are the culprit. If it's a newer chip, we'll need to dig deeper. Cheers, f - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] CocoaAgg backend status?
Michael, I'm sorry. I just realized I hadn't replied to you yet; sorry for the delay. John also pointed us to the transforms branch and that's where we'll start. Thanks! There's no real advantage to CoreAnimation per se (except eye candy), but going native for rendering would allow mpl to integrate more smoothly with the rest of the 2D and 3D (much of Quartz, and CoreImage the 2D rendering and filtering systems in OS X are actually rendered on the graphics card as OpenGL) rendering system in OS X. Some advantages, off the top of my head are resolution independence, ability to offload rendering and/or coordinate transformation to the graphics card, ability to easily produce output in any of the CoreImage supported formats, ability to incorporate transparency and alpha blending within the view hierarchy, ability to combine media (QuickTime, OpenGL, and Quartz) in layers (the real purpose of the CoreAnimation engine), ability to piggy back on improvements in Apple's rendering engine (things like anti-aliasing etc.), ColorSync support, and _maybe_ some speed improvements by taking a layer or two out of the rendering process. All of these are just speculation, at this time... we're just getting started but will share our results as soon as they're ready. barry On 12/5/07, Michael Droettboom [EMAIL PROTECTED] wrote: Barry Wark wrote: We (at my work) are just starting to think about writing a more direct Quartz backend for mpl. A native backend would let a matplotlib view participate in newer Cocoa technologies, such as resolution independence and CoreAnimation (it's possible with the current backend method, but not quite as flexible). I'm curious what Cocoa and CoreAnimation might enable... If you are looking into writing a Quartz rendering backend, you may want to start with the matplotlib transforms branch (which should become the trunk shortly, once the 0.91 release bugs get shaken out.) The number of methods that a backend writer must provide has been greatly reduced on that branch. Cheers, Mike -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] scipy on XP in VMWare Workstation
I am trying to run scipy in XP on VMWare Workstation. The host OS is Ubuntu. When I attempt to launch scipy I get the error: C:\Documents and Settings\AdministratorC:\Python25\python.exe C:\Python25\scrip ts\ipython -pylab -p scipy Traceback (most recent call last): File C:\Python25\scripts\ipython, line 27, in module IPython.Shell.start().mainloop() File C:\Python25\Lib\site-packages\IPython\Shell.py, line , in start return shell(user_ns = user_ns) File C:\Python25\Lib\site-packages\IPython\Shell.py, line 1008, in __init__ shell_class=MatplotlibShell) File C:\Python25\Lib\site-packages\IPython\Shell.py, line 74, in __init__ debug=debug,shell_class=shell_class) File C:\Python25\Lib\site-packages\IPython\ipmaker.py, line 95, in make_IPyt hon embedded=embedded,**kw) File C:\Python25\Lib\site-packages\IPython\Shell.py, line 562, in __init__ user_ns,b2 = self._matplotlib_config(name,user_ns) File C:\Python25\Lib\site-packages\IPython\Shell.py, line 463, in _matplotli b_config from matplotlib import backends File C:\Python25\Lib\site-packages\matplotlib\backends\__init__.py, line 55, in module new_figure_manager, draw_if_interactive, show = pylab_setup() File C:\Python25\Lib\site-packages\matplotlib\backends\__init__.py, line 24, in pylab_setup globals(),locals(),[backend_name]) File C:\Python25\Lib\site-packages\matplotlib\backends\backend_tkagg.py, lin e 8, in module import tkagg # Paint image to Tk photo blitter extension File C:\Python25\Lib\site-packages\matplotlib\backends\tkagg.py, line 1, in module import _tkagg ImportError: DLL load failed: The specified module could not be found. _ I changed the back end to WxAgg with no luck. _ import wx ImportError: no module named wx ___ Any thoughts? Thanks, Bill - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users