[Matplotlib-devel] Creating an interactive figure from the OO interface

Thomas Caswell tcaswell at gmail.com
Thu Sep 17 23:50:28 CEST 2015


If you are not going through pyplot you may have to manage
starting/integrating with the gui main-loop your self.

There is an on-going project (and one failed project) to pull apart
`new_figure_manager` and `pyplot`.

Tom

On Thu, Sep 17, 2015 at 4:53 PM Nathan Goldbaum <nathan12343 at gmail.com>
wrote:

> Just to follow up with a concrete example, the following code does seem to
> *draw* a plot on the matplotlib 1.5rc, but the gui loop seems to hang after
> calling show(), forcing me to kill the python process.
>
> ```
> import matplotlib.backends.backend_macosx as backend
> from matplotlib.figure import Figure
>
> manager = backend.new_figure_manager(0)
> fig = manager.canvas.figure
> ax = fig.add_subplot(1,1,1)
> ax.plot([1,2,3])
> fig.show()
> backend.show()
> ```
>
> If I do something similar via pyplot, everything works as expected:
>
> ```
> import matplotlib.pyplot as plt
> fig = plt.figure()
> ax = fig.add_subplot(1,1,1)
> ax.plot([1,2,3])
> plt.show()
> ```
>
> On Thu, Sep 17, 2015 at 3:44 PM, Nathan Goldbaum <nathan12343 at gmail.com>
> wrote:
>
>> Hi all,
>>
>> (resending this since I originally sent it to the old sourceforge list,
>> sorry if this double-posts)
>>
>> I see in the matplotlib 1.5 release notes that figures created via the OO
>> interface can now be interactively updated.
>>
>> Does this mean it's now possible to manually create a figure manager
>> using an interactive backend, create a plot using the figure manager and
>> then call the show() method on the figure manager to display the plot in an
>> interactive window, all without (possibly indirectly) importing pyplot? If
>> not, should I just give up and do this via pyplot? I'd like to avoid
>> importing pyplot if possible to avoid crashes on headless sessions.
>>
>> Thanks for your help or advice,
>>
>> Nathan
>>
>
> _______________________________________________
> Matplotlib-devel mailing list
> Matplotlib-devel at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-devel/attachments/20150917/2f9cef3d/attachment.html>


More information about the Matplotlib-devel mailing list