[Matplotlib-users] Use of Pyplot in a GUI script

Eric's Gmail eric.shain at gmail.com
Wed May 18 08:42:20 EDT 2016


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.


> On May 16, 2016, at 1:46 PM, Benjamin Root <ben.v.root at gmail.com> 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/ <http://www.amazon.com/Interactive-Applications-using-Matplotlib-Benjamin/dp/1783988843/>
> Cheers!
> Ben Root
> On Tue, Apr 26, 2016 at 5:28 PM, Eric <eric.shain at gmail.com <mailto:eric.shain at gmail.com>> 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 <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 <mailto:Matplotlib-users at python.org>
> https://mail.python.org/mailman/listinfo/matplotlib-users <https://mail.python.org/mailman/listinfo/matplotlib-users>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20160518/96d5b8ca/attachment-0001.html>

More information about the Matplotlib-users mailing list