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

Nathan Goldbaum nathan12343 at gmail.com
Thu Sep 17 22:52:58 CEST 2015


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-devel/attachments/20150917/855bcba8/attachment-0001.html>


More information about the Matplotlib-devel mailing list