From alexandre.candelon at cnrs-orleans.fr Mon May 9 10:57:07 2016 From: alexandre.candelon at cnrs-orleans.fr (Alexandre Candelon) Date: Mon, 09 May 2016 16:57:07 +0200 Subject: [Matplotlib-users] Matplotlib savefig .ps Message-ID: <5730A543.6080006@cnrs-orleans.fr> Hello, I have a problem with the function matplotlib.pyplot.savefig. I would like to create a png and a ps image from a plot. I try to save 2 specgrams on a page, with 2 000 000 points each. I have no problem with the .png file which is 361 kB, but with the .ps file, the size is huge : 450 MB! The size is huge, and the running time is very long too. So what can I do to reduce the file size and the running time? I tried every options of the function savefig, but it didn't went better... Thanks for your help, Regards -- ======================================== Alexandre CANDELON Ing?nieur d?veloppement TARANIS LPC2E/CNRS 3A Avenue de la Recherche Scientifique 45071 ORLEANS Cedex 2 ======================================== From eliu at hydro.mb.ca Fri May 13 18:06:59 2016 From: eliu at hydro.mb.ca (eliu) Date: Fri, 13 May 2016 15:06:59 -0700 (MST) Subject: [Matplotlib-users] how to specify time locator's start-ticking timestamp? Message-ID: <1463177219279-47066.post@n5.nabble.com> *All I want is quite straight forward, I just want the locator ticks to start at a specified timestamp: peudo code: locator.set_start_ticking_at( datetime_dummy ) I have no luck finding anything so far.* Here is the portion of the code for this question: axes[0].set_xlim(datetime_dummy) # datetime_dummy = '2015-12-25 05:34:00' import matplotlib.dates as matdates seclocator = matdates.SecondLocator(interval=20) minlocator = matdates.MinuteLocator(interval=1) hourlocator = matdates.HourLocator(interval=12) seclocator.MAXTICKS = 40000 minlocator.MAXTICKS = 40000 hourlocator.MAXTICKS = 40000 majorFmt = matdates.DateFormatter('%Y-%m-%d, %H:%M:%S') minorFmt = matdates.DateFormatter('%H:%M:%S') axes[0].xaxis.set_major_locator(minlocator) axes[0].xaxis.set_major_formatter(majorFmt) plt.setp(axes[0].xaxis.get_majorticklabels(), rotation=90 ) axes[0].xaxis.set_minor_locator(seclocator) axes[0].xaxis.set_minor_formatter(minorFmt) plt.setp(axes[0].xaxis.get_minorticklabels(), rotation=90 ) # other codes # save fig as a picture *The x axis ticks of above code will get me: * *How do I tell the minor locator to align with the major locator? How do I tell the locators which timestamp to start ticking at? what I have tried: set_xlim doesn't do the trick seclocator.tick_values(datetime_dummy, datetime_dummy1) doesn't do anything* -- View this message in context: http://matplotlib.1069221.n5.nabble.com/how-to-specify-time-locator-s-start-ticking-timestamp-tp47066.html Sent from the matplotlib - users mailing list archive at Nabble.com. From tanweiwei at pku.edu.cn Sun May 15 11:02:17 2016 From: tanweiwei at pku.edu.cn (tanweiwei at pku.edu.cn) Date: Sun, 15 May 2016 23:02:17 +0800 Subject: [Matplotlib-users] The dpi set is useless in my picture when using matplotlib Message-ID: <201605152302168535472@pku.edu.cn> I am learing to use matplotlib to produce high quality picture for my paper. The demand dpi of this magzine is 300. So, I wrote some example codes: import numpy as np import matplotlib.pyplot as plt a = np.linspace(0, 10, 100) b = np.linspace(0, 20, 100) plt.plot(a, b, 'o') plt.xlabel(r'$x$') plt.ylabel(r'$y$') plt.grid(True) plt.savefig('fig1.jpg', dpi=300, format='jpg') But I got a picure whose dpi is 72, and its size is 2400*1800. I'm confused about this outcome. I searched the Internet and some references about dpi setting, but I can't solve this problem anyway. Also I tried those: matplotlib.rcParams['savefig.dpi'] = 300 or plt.figure(dpi=300) or 'D:\Anaconda3\Lib\site-packages\matplotlib\mpl-data\matplotlibrc' in this file, make savefig.dpi=300. All of those is useless. I think the reason why the size of produced figure is 2400*1800. Because (300dpi*8 inches)*(300dpi*6 inches). The default size of figure in rc file is 8 inches and 6 inches. But why the dpi of this figure can't be changed! My operating system is windows 10. Anaconda 3 helped me to install matplotlib module. Thank for your help! Weiwei Tan Institute of Heavy Ion Physics School of ?Physics?Peking University -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdboom at gmail.com Mon May 16 13:49:43 2016 From: mdboom at gmail.com (Michael Droettboom) Date: Mon, 16 May 2016 17:49:43 +0000 Subject: [Matplotlib-users] Scipy John Hunter Plotting Contest: DEADLINE EXTENDED TO JUNE 3 Message-ID: The Scipy John Hunter Excellence in Plotting Contest is a great opportunity to showcase advancement in the start of the art of visualization. Entries are still welcome, as the deadline has been extended to June 3, 2016. Entry Instructions - Participants are invited to submit scientific plots to be judged by a panel. - Entries must be submitted by June 3, 2016 via e-mail to plotting-contest at scipy.org - Plots may be produced with any combination of Python-based tools. (It is not required that they use matplotlib, for example.) - Source code for the plot must be provided, in the form of Python code and/or IPython notebook, along with a rendering of the plot in PDF format. If the original data can not be shared for reasons of size or licensing, ?fake? data may be substituted, along with an image of the plot using real data. - Each entry must include a 300-500 word abstract describing the plot and its scientific importance for a general scientific audience. - Entries will be judged on their clarity, innovation and aesthetics, but most importantly for their effectiveness in illuminating real scientific work. Entrants are encouraged to submit plots that were used during the course of research, rather than merely being hypothetical. - SciPy reserves the right to display any and all entries, whether prize-winning or not, at the conference, use in any materials or on its website, with attribution to the original author(s). Michael Droettboom, chair Jacob Vanderplas Phil Elson ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From tcaswell at gmail.com Mon May 16 14:12:05 2016 From: tcaswell at gmail.com (Thomas Caswell) Date: Mon, 16 May 2016 18:12:05 +0000 Subject: [Matplotlib-users] The dpi set is useless in my picture when using matplotlib In-Reply-To: <201605152302168535472@pku.edu.cn> References: <201605152302168535472@pku.edu.cn> Message-ID: How are you determining that the figure dpi is still 72? Tom ps please subscribe to the mailing list so you can post with out moderation intervention. On Mon, May 16, 2016 at 1:53 PM tanweiwei at pku.edu.cn wrote: > I am learing to use matplotlib to produce high quality picture for my > paper. The demand dpi of this magzine is 300. > > So, I wrote some example codes: > > import numpy as npimport matplotlib.pyplot as plt > a = np.linspace(0, 10, 100) > b = np.linspace(0, 20, 100) > plt.plot(a, b, 'o') > plt.xlabel(r'$x$') > plt.ylabel(r'$y$') > plt.grid(True) > plt.savefig('fig1.jpg', dpi=300, format='jpg') > > But I got a picure whose dpi is 72, and its size is 2400*1800. I'm > confused about this outcome. I searched the Internet and some references > about dpi setting, but I can't solve this problem anyway. > > Also I tried those: > > matplotlib.rcParams['savefig.dpi'] = 300 > > or > > plt.figure(dpi=300) > > or > > 'D:\Anaconda3\Lib\site-packages\matplotlib\mpl-data\matplotlibrc' > > in this file, make > > savefig.dpi=300. > > *All of those is useless.* > > I think the reason why the size of produced figure is 2400*1800. Because > (300dpi*8 inches)*(300dpi*6 inches). The default size of figure in rc file > is 8 inches and 6 inches. But why the dpi of this figure can't be changed! > > My operating system is windows 10. Anaconda 3 helped me to install > matplotlib module. > > *Thank for your help!* > > ------------------------------ > *Weiwei Tan* > *Institute of Heavy Ion Physics* > *School of ?Physics?Peking University * > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pmhobson at gmail.com Mon May 16 14:35:09 2016 From: pmhobson at gmail.com (Paul Hobson) Date: Mon, 16 May 2016 11:35:09 -0700 Subject: [Matplotlib-users] Use of Pyplot in a GUI script In-Reply-To: <1461706136254-47030.post@n5.nabble.com> References: <1461706136254-47030.post@n5.nabble.com> Message-ID: This example for a app using WebAgg, but it doesn't use any pyplot functions: http://matplotlib.org/examples/pylab_examples/webapp_demo.html The main thing to remember is that you: 1) Create a figure (matplotlib.figure.Figure) 2) Use the figure object's method of add the axes (e.g., fig.add_subplot) 3) use methods attached to the axes to do everything else -p On Tue, Apr 26, 2016 at 2:28 PM, Eric wrote: > I've read that when writing a GUI application to avoid using pyplot. I > experienced this when I wrote a python script that called the tkinter file > dialog and then processed and plotted data. It would run when launched in > Ipython but would crash when run in the terminal. It ran in terminal when I > eliminated the file dialog and the file dialog code ran without the > plotting. I rewrote the script using pyqt4, and avoided using pyplot using > matplotlib figure instead. First question is is it true that I should avoid > any use of pyplot in a gui app? Second is that I find it hard to do things > in matplotlib that are easy in pyplot like drawing horizontal or vertical > lines and such. Is there documentation and code examples using the > matplotlib without pyplot? > > Thanks, Eric > > > > -- > View this message in context: > http://matplotlib.1069221.n5.nabble.com/Use-of-Pyplot-in-a-GUI-script-tp47030.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.v.root at gmail.com Mon May 16 14:46:20 2016 From: ben.v.root at gmail.com (Benjamin Root) Date: Mon, 16 May 2016 14:46:20 -0400 Subject: [Matplotlib-users] Use of Pyplot in a GUI script In-Reply-To: <1461706136254-47030.post@n5.nabble.com> References: <1461706136254-47030.post@n5.nabble.com> Message-ID: In general, yes, you should avoid using pyplot when embedding. However, that rule actually only needs to be strictly followed when you are embedding the matplotlib's canvas into your own instantiated Window object. If you are embedding GUI elements into a matplotlib figure window, you actually can still utilize pyplot (but very carefully). I suggest reading up my book: http://www.amazon.com/Interactive-Applications-using-Matplotlib-Benjamin/dp/1783988843/ Cheers! Ben Root On Tue, Apr 26, 2016 at 5:28 PM, Eric wrote: > I've read that when writing a GUI application to avoid using pyplot. I > experienced this when I wrote a python script that called the tkinter file > dialog and then processed and plotted data. It would run when launched in > Ipython but would crash when run in the terminal. It ran in terminal when I > eliminated the file dialog and the file dialog code ran without the > plotting. I rewrote the script using pyqt4, and avoided using pyplot using > matplotlib figure instead. First question is is it true that I should avoid > any use of pyplot in a gui app? Second is that I find it hard to do things > in matplotlib that are easy in pyplot like drawing horizontal or vertical > lines and such. Is there documentation and code examples using the > matplotlib without pyplot? > > Thanks, Eric > > > > -- > View this message in context: > http://matplotlib.1069221.n5.nabble.com/Use-of-Pyplot-in-a-GUI-script-tp47030.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joshuadevlin at gmail.com Mon May 16 18:18:09 2016 From: joshuadevlin at gmail.com (jaypeedevlin) Date: Mon, 16 May 2016 15:18:09 -0700 (MST) Subject: [Matplotlib-users] Matplotlib Tutorial - Dataquest Message-ID: <1463437089272-47098.post@n5.nabble.com> Hi All, We've just released a matplotlib tutorial aimed at users with no experience with MPL. We would love your feedback on it: https://www.dataquest.io/blog/matplotlib-tutorial/ Thanks in advance! -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Matplotlib-Tutorial-Dataquest-tp47098.html Sent from the matplotlib - users mailing list archive at Nabble.com. From efiring at hawaii.edu Mon May 16 22:19:13 2016 From: efiring at hawaii.edu (Eric Firing) Date: Mon, 16 May 2016 16:19:13 -1000 Subject: [Matplotlib-users] Install/Import error rcParams In-Reply-To: <1460973852988-46967.post@n5.nabble.com> References: <1460973852988-46967.post@n5.nabble.com> Message-ID: <9c414e83-4c1c-bdcb-bb34-a85d7c35d4c7@hawaii.edu> Please see https://github.com/matplotlib/matplotlib/issues/5420 for solutions. Eric On 2016/04/18 12:04 AM, yukicyk wrote: > Hi all, > > I am trying to install matplotlib on my iMac OSX El Capitan Version 10.114 > but failed. > OS info: Darwin OBs-iMac.local 15.4.0 Darwin Kernel Version 15.4.0: Fri Feb > 26 22:08:05 PST 2016; root:xnu-3248.40.184~3/RELEASE_X86_64 x86_64 > > gcc --version > Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr > --with-gxx-include-dir=/usr/include/c++/4.2.1 > Apple LLVM version 7.3.0 (clang-703.0.29) > Target: x86_64-apple-darwin15.4.0 > Thread model: posix > InstalledDir: > /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin > > I installed python using HomeBrew and pip install matplotlib. > > I got the following messages when i tried to import matplotlib: > > Python 2.7.11 (default, Jan 22 2016, 08:29:18) > [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin > Type "help", "copyright", "credits" or "license" for more information. >>>> import matplotlib > Traceback (most recent call last): > File "", line 1, in > File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line > 1131, in > rcParams = rc_params() > File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line > 975, in rc_params > return rc_params_from_file(fname, fail_on_error) > File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line > 1100, in rc_params_from_file > config_from_file = _rc_params_in_file(fname, fail_on_error) > File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line > 1018, in _rc_params_in_file > with _open_file_or_url(fname) as fd: > File > "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", > line 17, in __enter__ > return self.gen.next() > File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line > 1000, in _open_file_or_url > encoding = locale.getdefaultlocale()[1] > File > "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", > line 543, in getdefaultlocale > return _parse_localename(localename) > File > "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", > line 475, in _parse_localename > raise ValueError, 'unknown locale: %s' % localename > ValueError: unknown locale: UTF-8 > > > I later installed Anaconda hoping to resolve this problem, but still > encounter the same error. > Python 2.7.11 |Anaconda 4.0.0 (x86_64)| (default, Dec 6 2015, 18:57:58) > [GCC 4.2.1 (Apple Inc. build 5577)] on darwin > > I would greatly appreciate for any help on this. > > cheers, > yuki > > > > -- > View this message in context: http://matplotlib.1069221.n5.nabble.com/Install-Import-error-rcParams-tp46967.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > From tcaswell at gmail.com Mon May 16 22:44:19 2016 From: tcaswell at gmail.com (Thomas Caswell) Date: Tue, 17 May 2016 02:44:19 +0000 Subject: [Matplotlib-users] Matplotlib Tutorial - Dataquest In-Reply-To: <1463437089272-47098.post@n5.nabble.com> References: <1463437089272-47098.post@n5.nabble.com> Message-ID: I only have it a quick read, but it seems reasonable. I would suggest trying %matplotlib nbagg instead of inline. Tom On Mon, May 16, 2016, 18:18 jaypeedevlin wrote: > Hi All, > > We've just released a matplotlib tutorial aimed at users with no experience > with MPL. > > We would love your feedback on it: > > https://www.dataquest.io/blog/matplotlib-tutorial/ > > > Thanks in advance! > > > > -- > View this message in context: > http://matplotlib.1069221.n5.nabble.com/Matplotlib-Tutorial-Dataquest-tp47098.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pmhobson at gmail.com Tue May 17 11:18:25 2016 From: pmhobson at gmail.com (Paul Hobson) Date: Tue, 17 May 2016 08:18:25 -0700 Subject: [Matplotlib-users] Matplotlib Tutorial - Dataquest In-Reply-To: References: <1463437089272-47098.post@n5.nabble.com> Message-ID: I would recommend using one of the new style sheets for more aesthetic plots. First impressions and whatnot... -p On Mon, May 16, 2016 at 7:44 PM, Thomas Caswell wrote: > I only have it a quick read, but it seems reasonable. > > I would suggest trying %matplotlib nbagg instead of inline. > > Tom > > On Mon, May 16, 2016, 18:18 jaypeedevlin wrote: > >> Hi All, >> >> We've just released a matplotlib tutorial aimed at users with no >> experience >> with MPL. >> >> We would love your feedback on it: >> >> https://www.dataquest.io/blog/matplotlib-tutorial/ >> >> >> Thanks in advance! >> >> >> >> -- >> View this message in context: >> http://matplotlib.1069221.n5.nabble.com/Matplotlib-Tutorial-Dataquest-tp47098.html >> Sent from the matplotlib - users mailing list archive at Nabble.com. >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.v.root at gmail.com Tue May 17 13:15:44 2016 From: ben.v.root at gmail.com (Benjamin Root) Date: Tue, 17 May 2016 13:15:44 -0400 Subject: [Matplotlib-users] Matplotlib Tutorial - Dataquest In-Reply-To: References: <1463437089272-47098.post@n5.nabble.com> Message-ID: There are two sets of plots that probably could be better. The first is the histogram. The auto limits is causing its x-axis to start at -2 instead of zero. I think this is fixed in master, but it might be good to have the autoscaling be tight (there are a variety of ways to do this). Second, the code for the very last plot seems overly complicated. I am pretty sure you don't need to be shifting the bars yourself anymore. I know it used to be required, but I am pretty sure we fixed that, I think. (if not, we really should fix it). Ben Root On Tue, May 17, 2016 at 11:18 AM, Paul Hobson wrote: > I would recommend using one of the new style sheets for more aesthetic > plots. First impressions and whatnot... > -p > > On Mon, May 16, 2016 at 7:44 PM, Thomas Caswell > wrote: > >> I only have it a quick read, but it seems reasonable. >> >> I would suggest trying %matplotlib nbagg instead of inline. >> >> Tom >> >> On Mon, May 16, 2016, 18:18 jaypeedevlin wrote: >> >>> Hi All, >>> >>> We've just released a matplotlib tutorial aimed at users with no >>> experience >>> with MPL. >>> >>> We would love your feedback on it: >>> >>> https://www.dataquest.io/blog/matplotlib-tutorial/ >>> >>> >>> Thanks in advance! >>> >>> >>> >>> -- >>> View this message in context: >>> http://matplotlib.1069221.n5.nabble.com/Matplotlib-Tutorial-Dataquest-tp47098.html >>> Sent from the matplotlib - users mailing list archive at Nabble.com. >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Matplotlib-users at python.org >>> https://mail.python.org/mailman/listinfo/matplotlib-users >>> >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> >> > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jslavin at cfa.harvard.edu Tue May 17 14:55:29 2016 From: jslavin at cfa.harvard.edu (Slavin, Jonathan) Date: Tue, 17 May 2016 14:55:29 -0400 Subject: [Matplotlib-users] grouping in a legend Message-ID: Hi, I'm wondering if there's any way to group several items (i.e. handles) in a legend with a single label. Ideally I'd like to use something like a curly brace in the way one can in LaTeX using \right{. The use case is where you have several curves that share some characteristic and others that are different. This could be pushing legend beyond its limits. And of course I could just repeat the same label several times, but I thought I'd ask if anyone had come up with some clever way of doing this. Regards, Jon -- ________________________________________________________ Jonathan D. Slavin Harvard-Smithsonian CfA jslavin at cfa.harvard.edu 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA ________________________________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From tcaswell at gmail.com Tue May 17 15:05:24 2016 From: tcaswell at gmail.com (Thomas Caswell) Date: Tue, 17 May 2016 19:05:24 +0000 Subject: [Matplotlib-users] grouping in a legend In-Reply-To: References: Message-ID: The legends code is absurdly flexible, see http://matplotlib.org/users/legend_guide.html#legend-handlers and http://stackoverflow.com/questions/18007022/two-unique-marker-symbols-for-one-legend/18007565 Tom On Tue, May 17, 2016 at 2:55 PM Slavin, Jonathan wrote: > Hi, > > I'm wondering if there's any way to group several items (i.e. handles) in > a legend with a single label. Ideally I'd like to use something like a > curly brace in the way one can in LaTeX using \right{. The use case is > where you have several curves that share some characteristic and others > that are different. > This could be pushing legend beyond its limits. And of course I could > just repeat the same label several times, but I thought I'd ask if anyone > had come up with some clever way of doing this. > > Regards, > Jon > > -- > ________________________________________________________ > Jonathan D. Slavin Harvard-Smithsonian CfA > jslavin at cfa.harvard.edu 60 Garden Street, MS 83 > phone: (617) 496-7981 Cambridge, MA 02138-1516 > cell: (781) 363-0035 USA > ________________________________________________________ > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric.shain at gmail.com Wed May 18 08:42:20 2016 From: eric.shain at gmail.com (Eric's Gmail) Date: Wed, 18 May 2016 07:42:20 -0500 Subject: [Matplotlib-users] Use of Pyplot in a GUI script In-Reply-To: References: <1461706136254-47030.post@n5.nabble.com> Message-ID: Ben, I don?t really want a GUI application it this case. What I?m usually wanting is run pyplot with a file open dialog and a file save dialog. The file dialogs are important since I?m importing lots of json files and it would be a mess to try to type lots of long file names. I?ve tried several options including easygui, Tk and pyqt4. In theses cases, I can run them so long as I?m in an ipython console. However, as soon as I try to run from the terminal, I get a crash. I?ve managed by avoiding pyplot, but it is much nicer than using matplotlib without it. Eric > On May 16, 2016, at 1:46 PM, Benjamin Root wrote: > > In general, yes, you should avoid using pyplot when embedding. However, that rule actually only needs to be strictly followed when you are embedding the matplotlib's canvas into your own instantiated Window object. If you are embedding GUI elements into a matplotlib figure window, you actually can still utilize pyplot (but very carefully). > > I suggest reading up my book: http://www.amazon.com/Interactive-Applications-using-Matplotlib-Benjamin/dp/1783988843/ > > Cheers! > Ben Root > > > On Tue, Apr 26, 2016 at 5:28 PM, Eric > wrote: > I've read that when writing a GUI application to avoid using pyplot. I > experienced this when I wrote a python script that called the tkinter file > dialog and then processed and plotted data. It would run when launched in > Ipython but would crash when run in the terminal. It ran in terminal when I > eliminated the file dialog and the file dialog code ran without the > plotting. I rewrote the script using pyqt4, and avoided using pyplot using > matplotlib figure instead. First question is is it true that I should avoid > any use of pyplot in a gui app? Second is that I find it hard to do things > in matplotlib that are easy in pyplot like drawing horizontal or vertical > lines and such. Is there documentation and code examples using the > matplotlib without pyplot? > > Thanks, Eric > > > > -- > View this message in context: http://matplotlib.1069221.n5.nabble.com/Use-of-Pyplot-in-a-GUI-script-tp47030.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tcaswell at gmail.com Wed May 18 08:52:24 2016 From: tcaswell at gmail.com (Thomas Caswell) Date: Wed, 18 May 2016 12:52:24 +0000 Subject: [Matplotlib-users] Use of Pyplot in a GUI script In-Reply-To: References: <1461706136254-47030.post@n5.nabble.com> Message-ID: The crashes are likely due to conflicts between the multiple gui event loops, how ever with out a minimal example it is hard to say. pyplot functions are mostly auto-generated and have the form def foo(*args, **kwargs): retrun gca().foo(*args, **kwargs) so anything you can do in pyplot you can do via the OO api. Just take a look at the pyplot source for the functions you want to use and replace `gca` with an Axes object or `gcf` with a Figure object. Full Axes api docs: http://matplotlib.org/api/axes_api.html Tom On Wed, May 18, 2016 at 8:42 AM Eric's Gmail wrote: > Ben, > > I don?t really want a GUI application it this case. What I?m usually > wanting is run pyplot with a file open dialog and a file save dialog. The > file dialogs are important since I?m importing lots of json files and it > would be a mess to try to type lots of long file names. I?ve tried several > options including easygui, Tk and pyqt4. In theses cases, I can run them so > long as I?m in an ipython console. However, as soon as I try to run from > the terminal, I get a crash. I?ve managed by avoiding pyplot, but it is > much nicer than using matplotlib without it. > > Eric > > On May 16, 2016, at 1:46 PM, Benjamin Root wrote: > > In general, yes, you should avoid using pyplot when embedding. However, > that rule actually only needs to be strictly followed when you are > embedding the matplotlib's canvas into your own instantiated Window object. > If you are embedding GUI elements into a matplotlib figure window, you > actually can still utilize pyplot (but very carefully). > > I suggest reading up my book: > http://www.amazon.com/Interactive-Applications-using-Matplotlib-Benjamin/dp/1783988843/ > > Cheers! > Ben Root > > > On Tue, Apr 26, 2016 at 5:28 PM, Eric wrote: > >> I've read that when writing a GUI application to avoid using pyplot. I >> experienced this when I wrote a python script that called the tkinter file >> dialog and then processed and plotted data. It would run when launched in >> Ipython but would crash when run in the terminal. It ran in terminal when >> I >> eliminated the file dialog and the file dialog code ran without the >> plotting. I rewrote the script using pyqt4, and avoided using pyplot using >> matplotlib figure instead. First question is is it true that I should >> avoid >> any use of pyplot in a gui app? Second is that I find it hard to do things >> in matplotlib that are easy in pyplot like drawing horizontal or vertical >> lines and such. Is there documentation and code examples using the >> matplotlib without pyplot? >> >> Thanks, Eric >> >> >> >> -- >> View this message in context: >> http://matplotlib.1069221.n5.nabble.com/Use-of-Pyplot-in-a-GUI-script-tp47030.html >> Sent from the matplotlib - users mailing list archive at Nabble.com >> . >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric.shain at gmail.com Wed May 18 09:02:04 2016 From: eric.shain at gmail.com (Eric's Gmail) Date: Wed, 18 May 2016 08:02:04 -0500 Subject: [Matplotlib-users] Use of Pyplot in a GUI script In-Reply-To: References: <1461706136254-47030.post@n5.nabble.com> Message-ID: Thomas, This is a minimal example. In this case I?m not even plotting: from easygui import fileopenbox import matplotlib.pyplot as plt import numpy as np ft = ["JSON", ["*.jsn", "*.json"]] filename = fileopenbox(msg='Select JSON files',title='Import', filetypes=ft, multiple=False) print(filename) x = np.arange(10) y = x**2 Trying to run this from the terminal (OS X, 10.11.4, Python 3.5.1) yield the following: Erics-MacBook-Air:QTtest ericshain$ python plottest.py 2016-05-18 07:56:57.023 python[23268:3602317] -[NSApplication _setup:]: unrecognized selector sent to instance 0x109c3c500 2016-05-18 07:56:57.038 python[23268:3602317] An uncaught exception was raised 2016-05-18 07:56:57.039 python[23268:3602317] -[NSApplication _setup:]: unrecognized selector sent to instance 0x109c3c500 2016-05-18 07:56:57.039 python[23268:3602317] ( 0 CoreFoundation 0x00007fff8b1c94f2 __exceptionPreprocess + 178 1 libobjc.A.dylib 0x00007fff8897af7e objc_exception_throw + 48 2 CoreFoundation 0x00007fff8b2331ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 3 CoreFoundation 0x00007fff8b139571 ___forwarding___ + 1009 4 CoreFoundation 0x00007fff8b1390f8 _CF_forwarding_prep_0 + 120 5 libtk8.5.dylib 0x000000010161c76d TkpInit + 472 6 libtk8.5.dylib 0x0000000101594f91 Initialize + 1541 7 _tkinter.cpython-35m-darwin.so 0x00000001003efded Tcl_AppInit + 77 8 _tkinter.cpython-35m-darwin.so 0x00000001003ed7f9 _tkinter_create + 889 9 libpython3.5m.dylib 0x00000001000679d9 PyCFunction_Call + 233 10 libpython3.5m.dylib 0x00000001000f4cd7 PyEval_EvalFrameEx + 36647 11 libpython3.5m.dylib 0x00000001000f5900 _PyEval_EvalCodeWithName + 2400 12 libpython3.5m.dylib 0x00000001000f5a07 PyEval_EvalCodeEx + 71 13 libpython3.5m.dylib 0x00000001000426ba function_call + 186 14 libpython3.5m.dylib 0x000000010000de63 PyObject_Call + 99 15 libpython3.5m.dylib 0x000000010002b12c method_call + 140 16 libpython3.5m.dylib 0x000000010000de63 PyObject_Call + 99 17 libpython3.5m.dylib 0x0000000100080cc1 slot_tp_init + 81 18 libpython3.5m.dylib 0x000000010007b964 type_call + 212 19 libpython3.5m.dylib 0x000000010000de63 PyObject_Call + 99 20 libpython3.5m.dylib 0x00000001000edb9c PyEval_EvalFrameEx + 7660 21 libpython3.5m.dylib 0x00000001000f5900 _PyEval_EvalCodeWithName + 2400 22 libpython3.5m.dylib 0x00000001000f3c75 PyEval_EvalFrameEx + 32453 23 libpython3.5m.dylib 0x00000001000f5900 _PyEval_EvalCodeWithName + 2400 24 libpython3.5m.dylib 0x00000001000f5a61 PyEval_EvalCode + 81 25 libpython3.5m.dylib 0x00000001001247ee PyRun_FileExFlags + 206 26 libpython3.5m.dylib 0x0000000100124a8f PyRun_SimpleFileExFlags + 447 27 libpython3.5m.dylib 0x000000010013d497 Py_Main + 3479 28 python 0x0000000100000e92 main + 418 29 python 0x0000000100000cc4 start + 52 30 ??? 0x0000000000000002 0x0 + 2 ) 2016-05-18 07:56:57.039 python[23268:3602317] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x109c3c500' *** First throw call stack: ( 0 CoreFoundation 0x00007fff8b1c94f2 __exceptionPreprocess + 178 1 libobjc.A.dylib 0x00007fff8897af7e objc_exception_throw + 48 2 CoreFoundation 0x00007fff8b2331ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 3 CoreFoundation 0x00007fff8b139571 ___forwarding___ + 1009 4 CoreFoundation 0x00007fff8b1390f8 _CF_forwarding_prep_0 + 120 5 libtk8.5.dylib 0x000000010161c76d TkpInit + 472 6 libtk8.5.dylib 0x0000000101594f91 Initialize + 1541 7 _tkinter.cpython-35m-darwin.so 0x00000001003efded Tcl_AppInit + 77 8 _tkinter.cpython-35m-darwin.so 0x00000001003ed7f9 _tkinter_create + 889 9 libpython3.5m.dylib 0x00000001000679d9 PyCFunction_Call + 233 10 libpython3.5m.dylib 0x00000001000f4cd7 PyEval_EvalFrameEx + 36647 11 libpython3.5m.dylib 0x00000001000f5900 _PyEval_EvalCodeWithName + 2400 12 libpython3.5m.dylib 0x00000001000f5a07 PyEval_EvalCodeEx + 71 13 libpython3.5m.dylib 0x00000001000426ba function_call + 186 14 libpython3.5m.dylib 0x000000010000de63 PyObject_Call + 99 15 libpython3.5m.dylib 0x000000010002b12c method_call + 140 16 libpython3.5m.dylib 0x000000010000de63 PyObject_Call + 99 17 libpython3.5m.dylib 0x0000000100080cc1 slot_tp_init + 81 18 libpython3.5m.dylib 0x000000010007b964 type_call + 212 19 libpython3.5m.dylib 0x000000010000de63 PyObject_Call + 99 20 libpython3.5m.dylib 0x00000001000edb9c PyEval_EvalFrameEx + 7660 21 libpython3.5m.dylib 0x00000001000f5900 _PyEval_EvalCodeWithName + 2400 22 libpython3.5m.dylib 0x00000001000f3c75 PyEval_EvalFrameEx + 32453 23 libpython3.5m.dylib 0x00000001000f5900 _PyEval_EvalCodeWithName + 2400 24 libpython3.5m.dylib 0x00000001000f5a61 PyEval_EvalCode + 81 25 libpython3.5m.dylib 0x00000001001247ee PyRun_FileExFlags + 206 26 libpython3.5m.dylib 0x0000000100124a8f PyRun_SimpleFileExFlags + 447 27 libpython3.5m.dylib 0x000000010013d497 Py_Main + 3479 28 python 0x0000000100000e92 main + 418 29 python 0x0000000100000cc4 start + 52 30 ??? 0x0000000000000002 0x0 + 2 ) libc++abi.dylib: terminating with uncaught exception of type NSException Abort trap: 6 Eric > On May 18, 2016, at 7:52 AM, Thomas Caswell wrote: > > The crashes are likely due to conflicts between the multiple gui event loops, how ever with out a minimal example it is hard to say. > > pyplot functions are mostly auto-generated and have the form > > def foo(*args, **kwargs): > retrun gca().foo(*args, **kwargs) > > so anything you can do in pyplot you can do via the OO api. Just take a look at the pyplot source for the functions you want to use and replace `gca` with an Axes object or `gcf` with a Figure object. > > Full Axes api docs: http://matplotlib.org/api/axes_api.html > > Tom > > On Wed, May 18, 2016 at 8:42 AM Eric's Gmail > wrote: > Ben, > > I don?t really want a GUI application it this case. What I?m usually wanting is run pyplot with a file open dialog and a file save dialog. The file dialogs are important since I?m importing lots of json files and it would be a mess to try to type lots of long file names. I?ve tried several options including easygui, Tk and pyqt4. In theses cases, I can run them so long as I?m in an ipython console. However, as soon as I try to run from the terminal, I get a crash. I?ve managed by avoiding pyplot, but it is much nicer than using matplotlib without it. > > Eric > >> On May 16, 2016, at 1:46 PM, Benjamin Root > wrote: >> >> In general, yes, you should avoid using pyplot when embedding. However, that rule actually only needs to be strictly followed when you are embedding the matplotlib's canvas into your own instantiated Window object. If you are embedding GUI elements into a matplotlib figure window, you actually can still utilize pyplot (but very carefully). >> >> I suggest reading up my book: http://www.amazon.com/Interactive-Applications-using-Matplotlib-Benjamin/dp/1783988843/ >> >> Cheers! >> Ben Root >> >> >> On Tue, Apr 26, 2016 at 5:28 PM, Eric > wrote: >> I've read that when writing a GUI application to avoid using pyplot. I >> experienced this when I wrote a python script that called the tkinter file >> dialog and then processed and plotted data. It would run when launched in >> Ipython but would crash when run in the terminal. It ran in terminal when I >> eliminated the file dialog and the file dialog code ran without the >> plotting. I rewrote the script using pyqt4, and avoided using pyplot using >> matplotlib figure instead. First question is is it true that I should avoid >> any use of pyplot in a gui app? Second is that I find it hard to do things >> in matplotlib that are easy in pyplot like drawing horizontal or vertical >> lines and such. Is there documentation and code examples using the >> matplotlib without pyplot? >> >> Thanks, Eric >> >> >> >> -- >> View this message in context: http://matplotlib.1069221.n5.nabble.com/Use-of-Pyplot-in-a-GUI-script-tp47030.html >> Sent from the matplotlib - users mailing list archive at Nabble.com . >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From pmhobson at gmail.com Wed May 18 11:04:30 2016 From: pmhobson at gmail.com (Paul Hobson) Date: Wed, 18 May 2016 08:04:30 -0700 Subject: [Matplotlib-users] Use of Pyplot in a GUI script In-Reply-To: References: <1461706136254-47030.post@n5.nabble.com> Message-ID: Does that crash still occur if you don't import matplotlib? This doesn't look at a matplotlib issue to me. On Wed, May 18, 2016 at 6:02 AM, Eric's Gmail wrote: > Thomas, > > This is a minimal example. In this case I?m not even plotting: > > from easygui import fileopenbox > import matplotlib.pyplot as plt > import numpy as np > > ft = ["JSON", ["*.jsn", "*.json"]] > filename = fileopenbox(msg='Select JSON files',title='Import', > filetypes=ft, multiple=False) > print(filename) > x = np.arange(10) > y = x**2 > > Trying to run this from the terminal (OS X, 10.11.4, Python 3.5.1) yield > the following: > > Erics-MacBook-Air:QTtest ericshain$ python plottest.py > 2016-05-18 07:56:57.023 python[23268:3602317] -[NSApplication _setup:]: > unrecognized selector sent to instance 0x109c3c500 > 2016-05-18 07:56:57.038 python[23268:3602317] An uncaught exception was > raised > 2016-05-18 07:56:57.039 python[23268:3602317] -[NSApplication _setup:]: > unrecognized selector sent to instance 0x109c3c500 > 2016-05-18 07:56:57.039 python[23268:3602317] ( > 0 CoreFoundation 0x00007fff8b1c94f2 > __exceptionPreprocess + 178 > 1 libobjc.A.dylib 0x00007fff8897af7e > objc_exception_throw + 48 > 2 CoreFoundation 0x00007fff8b2331ad > -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 > 3 CoreFoundation 0x00007fff8b139571 > ___forwarding___ + 1009 > 4 CoreFoundation 0x00007fff8b1390f8 > _CF_forwarding_prep_0 + 120 > 5 libtk8.5.dylib 0x000000010161c76d TkpInit + 472 > 6 libtk8.5.dylib 0x0000000101594f91 Initialize + > 1541 > 7 _tkinter.cpython-35m-darwin.so 0x00000001003efded Tcl_AppInit + > 77 > 8 _tkinter.cpython-35m-darwin.so 0x00000001003ed7f9 > _tkinter_create + 889 > 9 libpython3.5m.dylib 0x00000001000679d9 > PyCFunction_Call + 233 > 10 libpython3.5m.dylib 0x00000001000f4cd7 > PyEval_EvalFrameEx + 36647 > 11 libpython3.5m.dylib 0x00000001000f5900 > _PyEval_EvalCodeWithName + 2400 > 12 libpython3.5m.dylib 0x00000001000f5a07 > PyEval_EvalCodeEx + 71 > 13 libpython3.5m.dylib 0x00000001000426ba function_call + > 186 > 14 libpython3.5m.dylib 0x000000010000de63 PyObject_Call + > 99 > 15 libpython3.5m.dylib 0x000000010002b12c method_call + > 140 > 16 libpython3.5m.dylib 0x000000010000de63 PyObject_Call + > 99 > 17 libpython3.5m.dylib 0x0000000100080cc1 slot_tp_init + > 81 > 18 libpython3.5m.dylib 0x000000010007b964 type_call + 212 > 19 libpython3.5m.dylib 0x000000010000de63 PyObject_Call + > 99 > 20 libpython3.5m.dylib 0x00000001000edb9c > PyEval_EvalFrameEx + 7660 > 21 libpython3.5m.dylib 0x00000001000f5900 > _PyEval_EvalCodeWithName + 2400 > 22 libpython3.5m.dylib 0x00000001000f3c75 > PyEval_EvalFrameEx + 32453 > 23 libpython3.5m.dylib 0x00000001000f5900 > _PyEval_EvalCodeWithName + 2400 > 24 libpython3.5m.dylib 0x00000001000f5a61 PyEval_EvalCode > + 81 > 25 libpython3.5m.dylib 0x00000001001247ee > PyRun_FileExFlags + 206 > 26 libpython3.5m.dylib 0x0000000100124a8f > PyRun_SimpleFileExFlags + 447 > 27 libpython3.5m.dylib 0x000000010013d497 Py_Main + 3479 > 28 python 0x0000000100000e92 main + 418 > 29 python 0x0000000100000cc4 start + 52 > 30 ??? 0x0000000000000002 0x0 + 2 > ) > 2016-05-18 07:56:57.039 python[23268:3602317] *** Terminating app due to > uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication > _setup:]: unrecognized selector sent to instance 0x109c3c500' > *** First throw call stack: > ( > 0 CoreFoundation 0x00007fff8b1c94f2 > __exceptionPreprocess + 178 > 1 libobjc.A.dylib 0x00007fff8897af7e > objc_exception_throw + 48 > 2 CoreFoundation 0x00007fff8b2331ad > -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 > 3 CoreFoundation 0x00007fff8b139571 > ___forwarding___ + 1009 > 4 CoreFoundation 0x00007fff8b1390f8 > _CF_forwarding_prep_0 + 120 > 5 libtk8.5.dylib 0x000000010161c76d TkpInit + 472 > 6 libtk8.5.dylib 0x0000000101594f91 Initialize + > 1541 > 7 _tkinter.cpython-35m-darwin.so 0x00000001003efded Tcl_AppInit + > 77 > 8 _tkinter.cpython-35m-darwin.so 0x00000001003ed7f9 > _tkinter_create + 889 > 9 libpython3.5m.dylib 0x00000001000679d9 > PyCFunction_Call + 233 > 10 libpython3.5m.dylib 0x00000001000f4cd7 > PyEval_EvalFrameEx + 36647 > 11 libpython3.5m.dylib 0x00000001000f5900 > _PyEval_EvalCodeWithName + 2400 > 12 libpython3.5m.dylib 0x00000001000f5a07 > PyEval_EvalCodeEx + 71 > 13 libpython3.5m.dylib 0x00000001000426ba function_call + > 186 > 14 libpython3.5m.dylib 0x000000010000de63 PyObject_Call + > 99 > 15 libpython3.5m.dylib 0x000000010002b12c method_call + > 140 > 16 libpython3.5m.dylib 0x000000010000de63 PyObject_Call + > 99 > 17 libpython3.5m.dylib 0x0000000100080cc1 slot_tp_init + > 81 > 18 libpython3.5m.dylib 0x000000010007b964 type_call + 212 > 19 libpython3.5m.dylib 0x000000010000de63 PyObject_Call + > 99 > 20 libpython3.5m.dylib 0x00000001000edb9c > PyEval_EvalFrameEx + 7660 > 21 libpython3.5m.dylib 0x00000001000f5900 > _PyEval_EvalCodeWithName + 2400 > 22 libpython3.5m.dylib 0x00000001000f3c75 > PyEval_EvalFrameEx + 32453 > 23 libpython3.5m.dylib 0x00000001000f5900 > _PyEval_EvalCodeWithName + 2400 > 24 libpython3.5m.dylib 0x00000001000f5a61 PyEval_EvalCode > + 81 > 25 libpython3.5m.dylib 0x00000001001247ee > PyRun_FileExFlags + 206 > 26 libpython3.5m.dylib 0x0000000100124a8f > PyRun_SimpleFileExFlags + 447 > 27 libpython3.5m.dylib 0x000000010013d497 Py_Main + 3479 > 28 python 0x0000000100000e92 main + 418 > 29 python 0x0000000100000cc4 start + 52 > 30 ??? 0x0000000000000002 0x0 + 2 > ) > libc++abi.dylib: terminating with uncaught exception of type NSException > Abort trap: 6 > > > Eric > > On May 18, 2016, at 7:52 AM, Thomas Caswell wrote: > > The crashes are likely due to conflicts between the multiple gui event > loops, how ever with out a minimal example it is hard to say. > > pyplot functions are mostly auto-generated and have the form > > def foo(*args, **kwargs): > retrun gca().foo(*args, **kwargs) > > so anything you can do in pyplot you can do via the OO api. Just take a > look at the pyplot source for the functions you want to use and replace > `gca` with an Axes object or `gcf` with a Figure object. > > Full Axes api docs: http://matplotlib.org/api/axes_api.html > > Tom > > On Wed, May 18, 2016 at 8:42 AM Eric's Gmail wrote: > >> Ben, >> >> I don?t really want a GUI application it this case. What I?m usually >> wanting is run pyplot with a file open dialog and a file save dialog. The >> file dialogs are important since I?m importing lots of json files and it >> would be a mess to try to type lots of long file names. I?ve tried several >> options including easygui, Tk and pyqt4. In theses cases, I can run them so >> long as I?m in an ipython console. However, as soon as I try to run from >> the terminal, I get a crash. I?ve managed by avoiding pyplot, but it is >> much nicer than using matplotlib without it. >> >> Eric >> >> On May 16, 2016, at 1:46 PM, Benjamin Root wrote: >> >> In general, yes, you should avoid using pyplot when embedding. However, >> that rule actually only needs to be strictly followed when you are >> embedding the matplotlib's canvas into your own instantiated Window object. >> If you are embedding GUI elements into a matplotlib figure window, you >> actually can still utilize pyplot (but very carefully). >> >> I suggest reading up my book: >> http://www.amazon.com/Interactive-Applications-using-Matplotlib-Benjamin/dp/1783988843/ >> >> Cheers! >> Ben Root >> >> >> On Tue, Apr 26, 2016 at 5:28 PM, Eric wrote: >> >>> I've read that when writing a GUI application to avoid using pyplot. I >>> experienced this when I wrote a python script that called the tkinter >>> file >>> dialog and then processed and plotted data. It would run when launched in >>> Ipython but would crash when run in the terminal. It ran in terminal >>> when I >>> eliminated the file dialog and the file dialog code ran without the >>> plotting. I rewrote the script using pyqt4, and avoided using pyplot >>> using >>> matplotlib figure instead. First question is is it true that I should >>> avoid >>> any use of pyplot in a gui app? Second is that I find it hard to do >>> things >>> in matplotlib that are easy in pyplot like drawing horizontal or vertical >>> lines and such. Is there documentation and code examples using the >>> matplotlib without pyplot? >>> >>> Thanks, Eric >>> >>> >>> >>> -- >>> View this message in context: >>> http://matplotlib.1069221.n5.nabble.com/Use-of-Pyplot-in-a-GUI-script-tp47030.html >>> Sent from the matplotlib - users mailing list archive at Nabble.com >>> . >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Matplotlib-users at python.org >>> https://mail.python.org/mailman/listinfo/matplotlib-users >>> >> >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric.shain at gmail.com Wed May 18 11:44:48 2016 From: eric.shain at gmail.com (Eric's Gmail) Date: Wed, 18 May 2016 10:44:48 -0500 Subject: [Matplotlib-users] Use of Pyplot in a GUI script In-Reply-To: References: <1461706136254-47030.post@n5.nabble.com> Message-ID: If I comment out the matplotib.pyplot call it runs fine. If i comment out the easygui call it also doesn?t crash. I can import Figure from matplotlib OK. Eric > On May 18, 2016, at 10:04 AM, Paul Hobson wrote: > > Does that crash still occur if you don't import matplotlib? This doesn't look at a matplotlib issue to me. > > On Wed, May 18, 2016 at 6:02 AM, Eric's Gmail > wrote: > Thomas, > > This is a minimal example. In this case I?m not even plotting: > > from easygui import fileopenbox > import matplotlib.pyplot as plt > import numpy as np > > ft = ["JSON", ["*.jsn", "*.json"]] > filename = fileopenbox(msg='Select JSON files',title='Import', filetypes=ft, multiple=False) > print(filename) > x = np.arange(10) > y = x**2 > > Trying to run this from the terminal (OS X, 10.11.4, Python 3.5.1) yield the following: > > Erics-MacBook-Air:QTtest ericshain$ python plottest.py > 2016-05-18 07:56:57.023 python[23268:3602317] -[NSApplication _setup:]: unrecognized selector sent to instance 0x109c3c500 > 2016-05-18 07:56:57.038 python[23268:3602317] An uncaught exception was raised > 2016-05-18 07:56:57.039 python[23268:3602317] -[NSApplication _setup:]: unrecognized selector sent to instance 0x109c3c500 > 2016-05-18 07:56:57.039 python[23268:3602317] ( > 0 CoreFoundation 0x00007fff8b1c94f2 __exceptionPreprocess + 178 > 1 libobjc.A.dylib 0x00007fff8897af7e objc_exception_throw + 48 > 2 CoreFoundation 0x00007fff8b2331ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 > 3 CoreFoundation 0x00007fff8b139571 ___forwarding___ + 1009 > 4 CoreFoundation 0x00007fff8b1390f8 _CF_forwarding_prep_0 + 120 > 5 libtk8.5.dylib 0x000000010161c76d TkpInit + 472 > 6 libtk8.5.dylib 0x0000000101594f91 Initialize + 1541 > 7 _tkinter.cpython-35m-darwin.so 0x00000001003efded Tcl_AppInit + 77 > 8 _tkinter.cpython-35m-darwin.so 0x00000001003ed7f9 _tkinter_create + 889 > 9 libpython3.5m.dylib 0x00000001000679d9 PyCFunction_Call + 233 > 10 libpython3.5m.dylib 0x00000001000f4cd7 PyEval_EvalFrameEx + 36647 > 11 libpython3.5m.dylib 0x00000001000f5900 _PyEval_EvalCodeWithName + 2400 > 12 libpython3.5m.dylib 0x00000001000f5a07 PyEval_EvalCodeEx + 71 > 13 libpython3.5m.dylib 0x00000001000426ba function_call + 186 > 14 libpython3.5m.dylib 0x000000010000de63 PyObject_Call + 99 > 15 libpython3.5m.dylib 0x000000010002b12c method_call + 140 > 16 libpython3.5m.dylib 0x000000010000de63 PyObject_Call + 99 > 17 libpython3.5m.dylib 0x0000000100080cc1 slot_tp_init + 81 > 18 libpython3.5m.dylib 0x000000010007b964 type_call + 212 > 19 libpython3.5m.dylib 0x000000010000de63 PyObject_Call + 99 > 20 libpython3.5m.dylib 0x00000001000edb9c PyEval_EvalFrameEx + 7660 > 21 libpython3.5m.dylib 0x00000001000f5900 _PyEval_EvalCodeWithName + 2400 > 22 libpython3.5m.dylib 0x00000001000f3c75 PyEval_EvalFrameEx + 32453 > 23 libpython3.5m.dylib 0x00000001000f5900 _PyEval_EvalCodeWithName + 2400 > 24 libpython3.5m.dylib 0x00000001000f5a61 PyEval_EvalCode + 81 > 25 libpython3.5m.dylib 0x00000001001247ee PyRun_FileExFlags + 206 > 26 libpython3.5m.dylib 0x0000000100124a8f PyRun_SimpleFileExFlags + 447 > 27 libpython3.5m.dylib 0x000000010013d497 Py_Main + 3479 > 28 python 0x0000000100000e92 main + 418 > 29 python 0x0000000100000cc4 start + 52 > 30 ??? 0x0000000000000002 0x0 + 2 > ) > 2016-05-18 07:56:57.039 python[23268:3602317] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x109c3c500' > *** First throw call stack: > ( > 0 CoreFoundation 0x00007fff8b1c94f2 __exceptionPreprocess + 178 > 1 libobjc.A.dylib 0x00007fff8897af7e objc_exception_throw + 48 > 2 CoreFoundation 0x00007fff8b2331ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 > 3 CoreFoundation 0x00007fff8b139571 ___forwarding___ + 1009 > 4 CoreFoundation 0x00007fff8b1390f8 _CF_forwarding_prep_0 + 120 > 5 libtk8.5.dylib 0x000000010161c76d TkpInit + 472 > 6 libtk8.5.dylib 0x0000000101594f91 Initialize + 1541 > 7 _tkinter.cpython-35m-darwin.so 0x00000001003efded Tcl_AppInit + 77 > 8 _tkinter.cpython-35m-darwin.so 0x00000001003ed7f9 _tkinter_create + 889 > 9 libpython3.5m.dylib 0x00000001000679d9 PyCFunction_Call + 233 > 10 libpython3.5m.dylib 0x00000001000f4cd7 PyEval_EvalFrameEx + 36647 > 11 libpython3.5m.dylib 0x00000001000f5900 _PyEval_EvalCodeWithName + 2400 > 12 libpython3.5m.dylib 0x00000001000f5a07 PyEval_EvalCodeEx + 71 > 13 libpython3.5m.dylib 0x00000001000426ba function_call + 186 > 14 libpython3.5m.dylib 0x000000010000de63 PyObject_Call + 99 > 15 libpython3.5m.dylib 0x000000010002b12c method_call + 140 > 16 libpython3.5m.dylib 0x000000010000de63 PyObject_Call + 99 > 17 libpython3.5m.dylib 0x0000000100080cc1 slot_tp_init + 81 > 18 libpython3.5m.dylib 0x000000010007b964 type_call + 212 > 19 libpython3.5m.dylib 0x000000010000de63 PyObject_Call + 99 > 20 libpython3.5m.dylib 0x00000001000edb9c PyEval_EvalFrameEx + 7660 > 21 libpython3.5m.dylib 0x00000001000f5900 _PyEval_EvalCodeWithName + 2400 > 22 libpython3.5m.dylib 0x00000001000f3c75 PyEval_EvalFrameEx + 32453 > 23 libpython3.5m.dylib 0x00000001000f5900 _PyEval_EvalCodeWithName + 2400 > 24 libpython3.5m.dylib 0x00000001000f5a61 PyEval_EvalCode + 81 > 25 libpython3.5m.dylib 0x00000001001247ee PyRun_FileExFlags + 206 > 26 libpython3.5m.dylib 0x0000000100124a8f PyRun_SimpleFileExFlags + 447 > 27 libpython3.5m.dylib 0x000000010013d497 Py_Main + 3479 > 28 python 0x0000000100000e92 main + 418 > 29 python 0x0000000100000cc4 start + 52 > 30 ??? 0x0000000000000002 0x0 + 2 > ) > libc++abi.dylib: terminating with uncaught exception of type NSException > Abort trap: 6 > > > Eric > >> On May 18, 2016, at 7:52 AM, Thomas Caswell > wrote: >> >> The crashes are likely due to conflicts between the multiple gui event loops, how ever with out a minimal example it is hard to say. >> >> pyplot functions are mostly auto-generated and have the form >> >> def foo(*args, **kwargs): >> retrun gca().foo(*args, **kwargs) >> >> so anything you can do in pyplot you can do via the OO api. Just take a look at the pyplot source for the functions you want to use and replace `gca` with an Axes object or `gcf` with a Figure object. >> >> Full Axes api docs: http://matplotlib.org/api/axes_api.html >> >> Tom >> >> On Wed, May 18, 2016 at 8:42 AM Eric's Gmail > wrote: >> Ben, >> >> I don?t really want a GUI application it this case. What I?m usually wanting is run pyplot with a file open dialog and a file save dialog. The file dialogs are important since I?m importing lots of json files and it would be a mess to try to type lots of long file names. I?ve tried several options including easygui, Tk and pyqt4. In theses cases, I can run them so long as I?m in an ipython console. However, as soon as I try to run from the terminal, I get a crash. I?ve managed by avoiding pyplot, but it is much nicer than using matplotlib without it. >> >> Eric >> >>> On May 16, 2016, at 1:46 PM, Benjamin Root > wrote: >>> >>> In general, yes, you should avoid using pyplot when embedding. However, that rule actually only needs to be strictly followed when you are embedding the matplotlib's canvas into your own instantiated Window object. If you are embedding GUI elements into a matplotlib figure window, you actually can still utilize pyplot (but very carefully). >>> >>> I suggest reading up my book: http://www.amazon.com/Interactive-Applications-using-Matplotlib-Benjamin/dp/1783988843/ >>> >>> Cheers! >>> Ben Root >>> >>> >>> On Tue, Apr 26, 2016 at 5:28 PM, Eric > wrote: >>> I've read that when writing a GUI application to avoid using pyplot. I >>> experienced this when I wrote a python script that called the tkinter file >>> dialog and then processed and plotted data. It would run when launched in >>> Ipython but would crash when run in the terminal. It ran in terminal when I >>> eliminated the file dialog and the file dialog code ran without the >>> plotting. I rewrote the script using pyqt4, and avoided using pyplot using >>> matplotlib figure instead. First question is is it true that I should avoid >>> any use of pyplot in a gui app? Second is that I find it hard to do things >>> in matplotlib that are easy in pyplot like drawing horizontal or vertical >>> lines and such. Is there documentation and code examples using the >>> matplotlib without pyplot? >>> >>> Thanks, Eric >>> >>> >>> >>> -- >>> View this message in context: http://matplotlib.1069221.n5.nabble.com/Use-of-Pyplot-in-a-GUI-script-tp47030.html >>> Sent from the matplotlib - users mailing list archive at Nabble.com . >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Matplotlib-users at python.org >>> https://mail.python.org/mailman/listinfo/matplotlib-users >>> >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From efiring at hawaii.edu Wed May 18 12:13:07 2016 From: efiring at hawaii.edu (Eric Firing) Date: Wed, 18 May 2016 06:13:07 -1000 Subject: [Matplotlib-users] Use of Pyplot in a GUI script In-Reply-To: References: <1461706136254-47030.post@n5.nabble.com> Message-ID: What happens if you put the following lines at the top: import matplotlib matplotlib.use('tkagg') Eric On 2016/05/18 5:44 AM, Eric's Gmail wrote: > If I comment out the matplotib.pyplot call it runs fine. If i comment > out the easygui call it also doesn?t crash. I can import Figure from > matplotlib OK. > > Eric > >> On May 18, 2016, at 10:04 AM, Paul Hobson > > wrote: >> >> Does that crash still occur if you don't import matplotlib? This >> doesn't look at a matplotlib issue to me. >> >> On Wed, May 18, 2016 at 6:02 AM, Eric's Gmail > > wrote: >> >> Thomas, >> >> This is a minimal example. In this case I?m not even plotting: >> >> from easygui import fileopenbox >> import matplotlib.pyplot as plt >> import numpy as np >> >> ft = ["JSON", ["*.jsn", "*.json"]] >> filename = fileopenbox(msg='Select JSON files',title='Import', >> filetypes=ft, multiple=False) >> print(filename) >> x = np.arange(10) >> y = x**2 >> >> Trying to run this from the terminal (OS X, 10.11.4, Python 3.5.1) >> yield the following: >> >> Erics-MacBook-Air:QTtest ericshain$ python plottest.py >> 2016-05-18 07:56:57.023 python[23268:3602317] -[NSApplication >> _setup:]: unrecognized selector sent to instance 0x109c3c500 >> 2016-05-18 07:56:57.038 python[23268:3602317] An uncaught >> exception was raised >> 2016-05-18 07:56:57.039 python[23268:3602317] -[NSApplication >> _setup:]: unrecognized selector sent to instance 0x109c3c500 >> 2016-05-18 07:56:57.039 python[23268:3602317] ( >> 0 CoreFoundation 0x00007fff8b1c94f2 >> __exceptionPreprocess + 178 >> 1 libobjc.A.dylib 0x00007fff8897af7e >> objc_exception_throw + 48 >> 2 CoreFoundation 0x00007fff8b2331ad >> -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 >> 3 CoreFoundation 0x00007fff8b139571 >> ___forwarding___ + 1009 >> 4 CoreFoundation 0x00007fff8b1390f8 >> _CF_forwarding_prep_0 + 120 >> 5 libtk8.5.dylib 0x000000010161c76d TkpInit >> + 472 >> 6 libtk8.5.dylib 0x0000000101594f91 >> Initialize + 1541 >> 7 _tkinter.cpython-35m-darwin.so >> 0x00000001003efded >> Tcl_AppInit + 77 >> 8 _tkinter.cpython-35m-darwin.so >> 0x00000001003ed7f9 >> _tkinter_create + 889 >> 9 libpython3.5m.dylib 0x00000001000679d9 >> PyCFunction_Call + 233 >> 10 libpython3.5m.dylib 0x00000001000f4cd7 >> PyEval_EvalFrameEx + 36647 >> 11 libpython3.5m.dylib 0x00000001000f5900 >> _PyEval_EvalCodeWithName + 2400 >> 12 libpython3.5m.dylib 0x00000001000f5a07 >> PyEval_EvalCodeEx + 71 >> 13 libpython3.5m.dylib 0x00000001000426ba >> function_call + 186 >> 14 libpython3.5m.dylib 0x000000010000de63 >> PyObject_Call + 99 >> 15 libpython3.5m.dylib 0x000000010002b12c >> method_call + 140 >> 16 libpython3.5m.dylib 0x000000010000de63 >> PyObject_Call + 99 >> 17 libpython3.5m.dylib 0x0000000100080cc1 >> slot_tp_init + 81 >> 18 libpython3.5m.dylib 0x000000010007b964 >> type_call + 212 >> 19 libpython3.5m.dylib 0x000000010000de63 >> PyObject_Call + 99 >> 20 libpython3.5m.dylib 0x00000001000edb9c >> PyEval_EvalFrameEx + 7660 >> 21 libpython3.5m.dylib 0x00000001000f5900 >> _PyEval_EvalCodeWithName + 2400 >> 22 libpython3.5m.dylib 0x00000001000f3c75 >> PyEval_EvalFrameEx + 32453 >> 23 libpython3.5m.dylib 0x00000001000f5900 >> _PyEval_EvalCodeWithName + 2400 >> 24 libpython3.5m.dylib 0x00000001000f5a61 >> PyEval_EvalCode + 81 >> 25 libpython3.5m.dylib 0x00000001001247ee >> PyRun_FileExFlags + 206 >> 26 libpython3.5m.dylib 0x0000000100124a8f >> PyRun_SimpleFileExFlags + 447 >> 27 libpython3.5m.dylib 0x000000010013d497 Py_Main >> + 3479 >> 28 python 0x0000000100000e92 main + 418 >> 29 python 0x0000000100000cc4 start + 52 >> 30 ??? 0x0000000000000002 0x0 + 2 >> ) >> 2016-05-18 07:56:57.039 python[23268:3602317] *** Terminating app >> due to uncaught exception 'NSInvalidArgumentException', reason: >> '-[NSApplication _setup:]: unrecognized selector sent to instance >> 0x109c3c500' >> *** First throw call stack: >> ( >> 0 CoreFoundation 0x00007fff8b1c94f2 >> __exceptionPreprocess + 178 >> 1 libobjc.A.dylib 0x00007fff8897af7e >> objc_exception_throw + 48 >> 2 CoreFoundation 0x00007fff8b2331ad >> -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 >> 3 CoreFoundation 0x00007fff8b139571 >> ___forwarding___ + 1009 >> 4 CoreFoundation 0x00007fff8b1390f8 >> _CF_forwarding_prep_0 + 120 >> 5 libtk8.5.dylib 0x000000010161c76d TkpInit >> + 472 >> 6 libtk8.5.dylib 0x0000000101594f91 >> Initialize + 1541 >> 7 _tkinter.cpython-35m-darwin.so >> 0x00000001003efded >> Tcl_AppInit + 77 >> 8 _tkinter.cpython-35m-darwin.so >> 0x00000001003ed7f9 >> _tkinter_create + 889 >> 9 libpython3.5m.dylib 0x00000001000679d9 >> PyCFunction_Call + 233 >> 10 libpython3.5m.dylib 0x00000001000f4cd7 >> PyEval_EvalFrameEx + 36647 >> 11 libpython3.5m.dylib 0x00000001000f5900 >> _PyEval_EvalCodeWithName + 2400 >> 12 libpython3.5m.dylib 0x00000001000f5a07 >> PyEval_EvalCodeEx + 71 >> 13 libpython3.5m.dylib 0x00000001000426ba >> function_call + 186 >> 14 libpython3.5m.dylib 0x000000010000de63 >> PyObject_Call + 99 >> 15 libpython3.5m.dylib 0x000000010002b12c >> method_call + 140 >> 16 libpython3.5m.dylib 0x000000010000de63 >> PyObject_Call + 99 >> 17 libpython3.5m.dylib 0x0000000100080cc1 >> slot_tp_init + 81 >> 18 libpython3.5m.dylib 0x000000010007b964 >> type_call + 212 >> 19 libpython3.5m.dylib 0x000000010000de63 >> PyObject_Call + 99 >> 20 libpython3.5m.dylib 0x00000001000edb9c >> PyEval_EvalFrameEx + 7660 >> 21 libpython3.5m.dylib 0x00000001000f5900 >> _PyEval_EvalCodeWithName + 2400 >> 22 libpython3.5m.dylib 0x00000001000f3c75 >> PyEval_EvalFrameEx + 32453 >> 23 libpython3.5m.dylib 0x00000001000f5900 >> _PyEval_EvalCodeWithName + 2400 >> 24 libpython3.5m.dylib 0x00000001000f5a61 >> PyEval_EvalCode + 81 >> 25 libpython3.5m.dylib 0x00000001001247ee >> PyRun_FileExFlags + 206 >> 26 libpython3.5m.dylib 0x0000000100124a8f >> PyRun_SimpleFileExFlags + 447 >> 27 libpython3.5m.dylib 0x000000010013d497 Py_Main >> + 3479 >> 28 python 0x0000000100000e92 main + 418 >> 29 python 0x0000000100000cc4 start + 52 >> 30 ??? 0x0000000000000002 0x0 + 2 >> ) >> libc++abi.dylib: terminating with uncaught exception of type >> NSException >> Abort trap: 6 >> >> >> Eric >> >>> On May 18, 2016, at 7:52 AM, Thomas Caswell >> > wrote: >>> >>> The crashes are likely due to conflicts between the multiple gui >>> event loops, how ever with out a minimal example it is hard to say. >>> >>> pyplot functions are mostly auto-generated and have the form >>> >>> def foo(*args, **kwargs): >>> retrun gca().foo(*args, **kwargs) >>> >>> so anything you can do in pyplot you can do via the OO api. Just >>> take a look at the pyplot source for the functions you want to >>> use and replace `gca` with an Axes object or `gcf` with a Figure >>> object. >>> >>> Full Axes api docs: http://matplotlib.org/api/axes_api.html >>> >>> Tom >>> >>> On Wed, May 18, 2016 at 8:42 AM Eric's Gmail >>> > wrote: >>> >>> Ben, >>> >>> I don?t really want a GUI application it this case. What I?m >>> usually wanting is run pyplot with a file open dialog and a >>> file save dialog. The file dialogs are important since I?m >>> importing lots of json files and it would be a mess to try to >>> type lots of long file names. I?ve tried several options >>> including easygui, Tk and pyqt4. In theses cases, I can run >>> them so long as I?m in an ipython console. However, as soon >>> as I try to run from the terminal, I get a crash. I?ve >>> managed by avoiding pyplot, but it is much nicer than using >>> matplotlib without it. >>> >>> Eric >>> >>>> On May 16, 2016, at 1:46 PM, Benjamin Root >>>> > wrote: >>>> >>>> In general, yes, you should avoid using pyplot when >>>> embedding. However, that rule actually only needs to be >>>> strictly followed when you are embedding the matplotlib's >>>> canvas into your own instantiated Window object. If you are >>>> embedding GUI elements into a matplotlib figure window, you >>>> actually can still utilize pyplot (but very carefully). >>>> >>>> I suggest reading up my book: >>>> http://www.amazon.com/Interactive-Applications-using-Matplotlib-Benjamin/dp/1783988843/ >>>> >>>> Cheers! >>>> Ben Root >>>> >>>> >>>> On Tue, Apr 26, 2016 at 5:28 PM, Eric >>> > wrote: >>>> >>>> I've read that when writing a GUI application to avoid >>>> using pyplot. I >>>> experienced this when I wrote a python script that >>>> called the tkinter file >>>> dialog and then processed and plotted data. It would run >>>> when launched in >>>> Ipython but would crash when run in the terminal. It ran >>>> in terminal when I >>>> eliminated the file dialog and the file dialog code ran >>>> without the >>>> plotting. I rewrote the script using pyqt4, and avoided >>>> using pyplot using >>>> matplotlib figure instead. First question is is it true >>>> that I should avoid >>>> any use of pyplot in a gui app? Second is that I find it >>>> hard to do things >>>> in matplotlib that are easy in pyplot like drawing >>>> horizontal or vertical >>>> lines and such. Is there documentation and code examples >>>> using the >>>> matplotlib without pyplot? >>>> >>>> Thanks, Eric >>>> >>>> >>>> >>>> -- >>>> View this message in context: >>>> http://matplotlib.1069221.n5.nabble.com/Use-of-Pyplot-in-a-GUI-script-tp47030.html >>>> Sent from the matplotlib - users mailing list archive at >>>> Nabble.com . >>>> _______________________________________________ >>>> Matplotlib-users mailing list >>>> Matplotlib-users at python.org >>>> >>>> https://mail.python.org/mailman/listinfo/matplotlib-users >>>> >>>> >>> >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Matplotlib-users at python.org >>> https://mail.python.org/mailman/listinfo/matplotlib-users >>> >> >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> >> > > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > From eric.shain at gmail.com Wed May 18 13:05:55 2016 From: eric.shain at gmail.com (Eric's Gmail) Date: Wed, 18 May 2016 12:05:55 -0500 Subject: [Matplotlib-users] Use of Pyplot in a GUI script In-Reply-To: References: <1461706136254-47030.post@n5.nabble.com> Message-ID: Awesome! This works so long as I callout before the importing of pyplot. Eric > On May 18, 2016, at 11:13 AM, Eric Firing wrote: > > matplotlib.use('tkagg') -------------- next part -------------- An HTML attachment was scrubbed... URL: From jason.swails at gmail.com Thu May 19 08:12:58 2016 From: jason.swails at gmail.com (Jason Swails) Date: Thu, 19 May 2016 08:12:58 -0400 Subject: [Matplotlib-users] Use of Pyplot in a GUI script In-Reply-To: References: <1461706136254-47030.post@n5.nabble.com> Message-ID: FWIW, I wrote a Tkinter-based GUI program several years ago where I embedded a matplotlib canvas in my own window, and I used pyplot just fine. I put it up on GitHub yesterday which you can use as an example ( https://github.com/swails/mdout_analyzer) in case it helps. For me, also, the key ingredient was setting the Tk backend to avoid competing mainloops for the different GUI toolkits. The reason I embedded the matplotlib graphs in my own window is so that I could destroy those windows when the main control window was closed (if you rely on matplotlib to create the windows for you, you can't control that window as easily from other parts of your application). All the best, Jason On Wed, May 18, 2016 at 1:05 PM, Eric's Gmail wrote: > Awesome! > > This works so long as I callout before the importing of pyplot. > > Eric > > On May 18, 2016, at 11:13 AM, Eric Firing wrote: > > matplotlib.use('tkagg') > > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > -- Jason M. Swails -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.v.root at gmail.com Thu May 19 12:10:13 2016 From: ben.v.root at gmail.com (Benjamin Root) Date: Thu, 19 May 2016 12:10:13 -0400 Subject: [Matplotlib-users] Use of Pyplot in a GUI script In-Reply-To: References: <1461706136254-47030.post@n5.nabble.com> Message-ID: Does that still work with current matplotlib? The import of pyplot triggers the call to pylab_setup(), which causes matplotlib to assume that it will be responsible for managing the windows. It might also be that Tkinter might be the odd backend in this case and that this wouldn't be portable to other backends. The tkagg backend has a bunch of oddities that makes it different from the others. On Thu, May 19, 2016 at 8:12 AM, Jason Swails wrote: > FWIW, I wrote a Tkinter-based GUI program several years ago where I > embedded a matplotlib canvas in my own window, and I used pyplot just > fine. I put it up on GitHub yesterday which you can use as an example ( > https://github.com/swails/mdout_analyzer) in case it helps. > > For me, also, the key ingredient was setting the Tk backend to avoid > competing mainloops for the different GUI toolkits. The reason I embedded > the matplotlib graphs in my own window is so that I could destroy those > windows when the main control window was closed (if you rely on matplotlib > to create the windows for you, you can't control that window as easily from > other parts of your application). > > All the best, > Jason > > On Wed, May 18, 2016 at 1:05 PM, Eric's Gmail > wrote: > >> Awesome! >> >> This works so long as I callout before the importing of pyplot. >> >> Eric >> >> On May 18, 2016, at 11:13 AM, Eric Firing wrote: >> >> matplotlib.use('tkagg') >> >> >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> >> > > > -- > Jason M. Swails > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From duncan.macleod at ligo.org Fri May 20 12:46:04 2016 From: duncan.macleod at ligo.org (Duncan Macleod) Date: Fri, 20 May 2016 11:46:04 -0500 Subject: [Matplotlib-users] How to register custom font (from ttf) with matplotlib Message-ID: Hi all, I have a custom font file (ttf) I would like to use with matplotlib. I don't have sudo access, so can't just add it to the standard fonts directory, but would like to add it to matplotlib's list of known fonts. I know that I can do something like this for one-off uses: from matplotlib import font_manager fp = font_manager.FontProperties(fname='myfont.ttf') fig = pyplot.figure() ax = fig.gca() ax.plot([1, 2, 3, 4, 5]) ax.set_xlabel('X-axis label', fontproperties=fp) But I would like to use the font as the default for all text objects in my figure. I have tried using rcParams: rcParams['font.family'] = fp.get_family() rcParams['font.sans-serif'] = fp.get_name() but I get the standard warning: UserWarning: findfont: Font family [u'sans-serif'] not found. Falling back to Bitstream Vera Sans and it uses the default font, even after blowing away my fontList.cache file (many times). I suspect that I have loaded the font using the FontProperties object, but haven't actually 'registered' it with matplotlib so it knows what to do when I specify the font name, or something like that. Any help would be great. Many thanks Duncan -- Duncan Macleod duncan.macleod at ligo.org LIGO Data Grid systems development Louisiana State University -------------- next part -------------- An HTML attachment was scrubbed... URL: From tcaswell at gmail.com Fri May 27 00:02:25 2016 From: tcaswell at gmail.com (Thomas Caswell) Date: Fri, 27 May 2016 04:02:25 +0000 Subject: [Matplotlib-users] REL: mpl v1.5.2rc2 Message-ID: Folks, The second release candidate for 1.5.2 has been tagged. conda binaries are available via conda install -c conda-forge/channel/rc matplotlib -c conda-forge on all platforms. Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: From ndbecker2 at gmail.com Fri May 27 07:53:07 2016 From: ndbecker2 at gmail.com (Neal Becker) Date: Fri, 27 May 2016 07:53:07 -0400 Subject: [Matplotlib-users] REL: mpl v1.5.2rc2 References: Message-ID: Thomas Caswell wrote: > Folks, > > The second release candidate for 1.5.2 has been tagged. > > conda binaries are available via > > conda install -c conda-forge/channel/rc matplotlib -c conda-forge > > on all platforms. > > Tom I tried the conda install, and it broke mpl for me. See: https://gist.github.com/nbecker/9ee0957a54d28eb8c2b801d557f89c5f From tcaswell at gmail.com Fri May 27 08:04:57 2016 From: tcaswell at gmail.com (Thomas Caswell) Date: Fri, 27 May 2016 12:04:57 +0000 Subject: [Matplotlib-users] REL: mpl v1.5.2rc2 In-Reply-To: References: Message-ID: Can you try also installing qt/pyqt from conda forge? Can you import pyqt with out going through mpl? Tom On Fri, May 27, 2016, 07:53 Neal Becker wrote: > Thomas Caswell wrote: > > > Folks, > > > > The second release candidate for 1.5.2 has been tagged. > > > > conda binaries are available via > > > > conda install -c conda-forge/channel/rc matplotlib -c conda-forge > > > > on all platforms. > > > > Tom > > I tried the conda install, and it broke mpl for me. See: > > https://gist.github.com/nbecker/9ee0957a54d28eb8c2b801d557f89c5f > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ndbecker2 at gmail.com Fri May 27 08:25:26 2016 From: ndbecker2 at gmail.com (Neal Becker) Date: Fri, 27 May 2016 08:25:26 -0400 Subject: [Matplotlib-users] REL: mpl v1.5.2rc2 References: Message-ID: Thomas Caswell wrote: > Can you try also installing qt/pyqt from conda forge? > > Can you import pyqt with out going through mpl? > > Tom > > On Fri, May 27, 2016, 07:53 Neal Becker > wrote: > >> Thomas Caswell wrote: >> >> > Folks, >> > >> > The second release candidate for 1.5.2 has been tagged. >> > >> > conda binaries are available via >> > >> > conda install -c conda-forge/channel/rc matplotlib -c conda-forge >> > >> > on all platforms. >> > >> > Tom >> >> I tried the conda install, and it broke mpl for me. See: >> >> https://gist.github.com/nbecker/9ee0957a54d28eb8c2b801d557f89c5f >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> OK, this seems to work: conda install -c conda-forge/channel/rc icu matplotlib -c conda-forge From ndbecker2 at gmail.com Fri May 27 08:30:55 2016 From: ndbecker2 at gmail.com (Neal Becker) Date: Fri, 27 May 2016 08:30:55 -0400 Subject: [Matplotlib-users] bug in double subscript LaTeX? Message-ID: The following test code doesn't render the _1 and _2 as double subscript. Is this a bug? import matplotlib.pyplot as plt esno1dB = 10; esno2dB=10 plt.suptitle (r'${E_s/N_0}_1=%g, {E_s/N_0}_2=%g$'%(esno1dB,esno2dB)) plt.show() From grivet at cnrs-orleans.fr Mon May 30 06:17:23 2016 From: grivet at cnrs-orleans.fr (grivet) Date: Mon, 30 May 2016 12:17:23 +0200 Subject: [Matplotlib-users] mouse cursor coordinates Message-ID: <70ce75f7-c8d7-58b8-06c4-3f859646a2ed@cnrs-orleans.fr> Hello, I want to retrieve the mouse cursor coordinates when i click inside a figure. I have tried a variety ef example programs, such as from pylab import * fig = plt.figure() ax = fig.add_subplot(111) ax.plot(np.random.rand(10)) def onclick(event): print("button=%d, x=%d, y=%d, xdata=%f, ydata=%f" %( event.button, event.x, event.y, event.xdata, event.ydata)) cid = fig.canvas.mpl_connect('button_press_event', onclick) ax.set_title("click on figure") show() The figure gets plotted, then nothing happens: the program simply ends and focus retruns to the IPython console. I am using distribution Anaconda/Python35/Spyder under Win7-64. What did I miss ? Thank you for your help, JP Grivet From fiolj at yahoo.com Mon May 30 08:36:47 2016 From: fiolj at yahoo.com (Juan) Date: Mon, 30 May 2016 09:36:47 -0300 Subject: [Matplotlib-users] mouse cursor coordinates In-Reply-To: <70ce75f7-c8d7-58b8-06c4-3f859646a2ed@cnrs-orleans.fr> References: <70ce75f7-c8d7-58b8-06c4-3f859646a2ed@cnrs-orleans.fr> Message-ID: <3fbfd83e-f164-ccb1-9644-391cd4735a42@yahoo.com> It works well in my system (linux gentoo) with ipython-4.0.3, python-2.7.10 and python-3.4.3. Did you try running it outside spyder? May be save it into a file (test_cursor.py) and run it directly from a system console to see if the problem is with spyder. Anyway, I am not very experienced. May be someone else may have a better advice. Regards, Juan On 30/05/16 07:17, grivet wrote: > Hello, > I want to retrieve the mouse cursor coordinates when i click inside a > figure. I have tried a variety ef example programs, such as > > from pylab import * > > fig = plt.figure() > ax = fig.add_subplot(111) > ax.plot(np.random.rand(10)) > > def onclick(event): > print("button=%d, x=%d, y=%d, xdata=%f, ydata=%f" %( > event.button, event.x, event.y, event.xdata, event.ydata)) > > cid = fig.canvas.mpl_connect('button_press_event', onclick) > ax.set_title("click on figure") > > show() > > The figure gets plotted, then nothing happens: the program simply ends > and focus retruns to the IPython console. > > I am using distribution Anaconda/Python35/Spyder under Win7-64. What did > I miss ? > Thank you for your help, > JP Grivet > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users From grivet at cnrs-orleans.fr Mon May 30 10:40:54 2016 From: grivet at cnrs-orleans.fr (grivet) Date: Mon, 30 May 2016 16:40:54 +0200 Subject: [Matplotlib-users] mouse cursor coordinates In-Reply-To: <3fbfd83e-f164-ccb1-9644-391cd4735a42@yahoo.com> References: <70ce75f7-c8d7-58b8-06c4-3f859646a2ed@cnrs-orleans.fr> <3fbfd83e-f164-ccb1-9644-391cd4735a42@yahoo.com> Message-ID: Le 30/05/2016 ? 14:36, Juan a ?crit : > It works well in my system (linux gentoo) with ipython-4.0.3, > python-2.7.10 and python-3.4.3. > > Did you try running it outside spyder? > May be save it into a file (test_cursor.py) and run it directly from a > system console to see if the problem is with spyder. > > Anyway, I am not very experienced. May be someone else may have a better > advice. > Regards, > Juan > > > On 30/05/16 07:17, grivet wrote: >> Hello, >> I want to retrieve the mouse cursor coordinates when i click inside a >> figure. I have tried a variety ef example programs, such as >> >> from pylab import * >> >> fig = plt.figure() >> ax = fig.add_subplot(111) >> ax.plot(np.random.rand(10)) >> >> def onclick(event): >> print("button=%d, x=%d, y=%d, xdata=%f, ydata=%f" %( >> event.button, event.x, event.y, event.xdata, event.ydata)) >> >> cid = fig.canvas.mpl_connect('button_press_event', onclick) >> ax.set_title("click on figure") >> >> show() >> >> The figure gets plotted, then nothing happens: the program simply ends >> and focus retruns to the IPython console. >> >> I am using distribution Anaconda/Python35/Spyder under Win7-64. What did >> I miss ? >> Thank you for your help, >> JP Grivet >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users Juan, It seems you are right; all the examples I had tried unsuccessfully before work OK when launched in command window . What should I do next ? JP Grivet From fiolj at yahoo.com Mon May 30 11:11:44 2016 From: fiolj at yahoo.com (Juan) Date: Mon, 30 May 2016 12:11:44 -0300 Subject: [Matplotlib-users] mouse cursor coordinates In-Reply-To: References: <70ce75f7-c8d7-58b8-06c4-3f859646a2ed@cnrs-orleans.fr> <3fbfd83e-f164-ccb1-9644-391cd4735a42@yahoo.com> Message-ID: Ok, I do not use spyder so I may be wrong, but it looks that it works if in the preferences windows (Tools -> Preferences) in the option: "IPython console" In the tab: "Graphics" you select the Backend: "Automatic" You probably have to restart spyder for it to work. Regards, Juan On 30/05/16 11:40, grivet wrote: > Le 30/05/2016 ? 14:36, Juan a ?crit : >> It works well in my system (linux gentoo) with ipython-4.0.3, >> python-2.7.10 and python-3.4.3. >> >> Did you try running it outside spyder? >> May be save it into a file (test_cursor.py) and run it directly from a >> system console to see if the problem is with spyder. >> >> Anyway, I am not very experienced. May be someone else may have a better >> advice. >> Regards, >> Juan >> >> >> On 30/05/16 07:17, grivet wrote: >>> Hello, >>> I want to retrieve the mouse cursor coordinates when i click inside a >>> figure. I have tried a variety ef example programs, such as >>> >>> from pylab import * >>> >>> fig = plt.figure() >>> ax = fig.add_subplot(111) >>> ax.plot(np.random.rand(10)) >>> >>> def onclick(event): >>> print("button=%d, x=%d, y=%d, xdata=%f, ydata=%f" %( >>> event.button, event.x, event.y, event.xdata, event.ydata)) >>> >>> cid = fig.canvas.mpl_connect('button_press_event', onclick) >>> ax.set_title("click on figure") >>> >>> show() >>> >>> The figure gets plotted, then nothing happens: the program simply ends >>> and focus retruns to the IPython console. >>> >>> I am using distribution Anaconda/Python35/Spyder under Win7-64. What did >>> I miss ? >>> Thank you for your help, >>> JP Grivet >>> >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Matplotlib-users at python.org >>> https://mail.python.org/mailman/listinfo/matplotlib-users > > Juan, > > It seems you are right; all the examples I had tried unsuccessfully > before work OK when launched in command > > window . What should I do next ? > > JP Grivet > > From grivet at cnrs-orleans.fr Tue May 31 05:33:23 2016 From: grivet at cnrs-orleans.fr (grivet) Date: Tue, 31 May 2016 11:33:23 +0200 Subject: [Matplotlib-users] mouse cursor coordinates In-Reply-To: References: <70ce75f7-c8d7-58b8-06c4-3f859646a2ed@cnrs-orleans.fr> <3fbfd83e-f164-ccb1-9644-391cd4735a42@yahoo.com> Message-ID: <6d397a8a-8b9d-3c58-e4ad-eb640a02c3a5@cnrs-orleans.fr> Right again! A separate window is now created and I can click inside and retrieve the pointer coordinates. Thanks a lot, JP Grivet > Ok, I do not use spyder so I may be wrong, but it looks that it works if > in the preferences windows (Tools -> Preferences) > in the option: > "IPython console" > In the tab: > "Graphics" > you select the Backend: > "Automatic" > > You probably have to restart spyder for it to work. > > Regards, > Juan > > On 30/05/16 11:40, grivet wrote: >> Le 30/05/2016 ? 14:36, Juan a ?crit : >>> It works well in my system (linux gentoo) with ipython-4.0.3, >>> python-2.7.10 and python-3.4.3. >>> >>> Did you try running it outside spyder? >>> May be save it into a file (test_cursor.py) and run it directly from a >>> system console to see if the problem is with spyder. >>> >>> Anyway, I am not very experienced. May be someone else may have a better >>> advice. >>> Regards, >>> Juan >>> >>> >>> On 30/05/16 07:17, grivet wrote: >>>> Hello, >>>> I want to retrieve the mouse cursor coordinates when i click inside a >>>> figure. I have tried a variety ef example programs, such as >>>> >>>> from pylab import * >>>> >>>> fig = plt.figure() >>>> ax = fig.add_subplot(111) >>>> ax.plot(np.random.rand(10)) >>>> >>>> def onclick(event): >>>> print("button=%d, x=%d, y=%d, xdata=%f, ydata=%f" %( >>>> event.button, event.x, event.y, event.xdata, event.ydata)) >>>> >>>> cid = fig.canvas.mpl_connect('button_press_event', onclick) >>>> ax.set_title("click on figure") >>>> >>>> show() >>>> >>>> The figure gets plotted, then nothing happens: the program simply ends >>>> and focus retruns to the IPython console. >>>> >>>> I am using distribution Anaconda/Python35/Spyder under Win7-64. What did >>>> I miss ? >>>> Thank you for your help, >>>> JP Grivet >>>> >>>> _______________________________________________ >>>> Matplotlib-users mailing list >>>> Matplotlib-users at python.org >>>> https://mail.python.org/mailman/listinfo/matplotlib-users >> Juan, >> >> It seems you are right; all the examples I had tried unsuccessfully >> before work OK when launched in command >> >> window . What should I do next ? >> >> JP Grivet >> >>