[Matplotlib-users] Use of Pyplot in a GUI script
tcaswell at gmail.com
Wed May 18 08:52:24 EDT 2016
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
On Wed, May 18, 2016 at 8:42 AM Eric's Gmail <eric.shain at gmail.com> wrote:
> 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:
> Ben Root
> On Tue, Apr 26, 2016 at 5:28 PM, Eric <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
>> 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
>> 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:
>> Sent from the matplotlib - users mailing list archive at Nabble.com
>> Matplotlib-users mailing list
>> Matplotlib-users at python.org
> Matplotlib-users mailing list
> Matplotlib-users at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Matplotlib-users