docking the matplotlib window

1,572 views
Skip to first unread message

bgbg bg

unread,
Dec 13, 2010, 9:18:21 AM12/13/10
to spyd...@googlegroups.com
Hello,
is it possible to dock the matplotlib graph window to the main spyder
window, the way it is possible in Matlab. I'm using the 2.0.1 version
of Spyderlib on windows and in this version the newly created graphs
are created in a separate window, which makes me switching between the
editor/console to the graph every time I update my plots?

Thank you

Pierre Raybaut

unread,
Dec 13, 2010, 11:52:24 AM12/13/10
to spyder
Hi,

In Spyder v1.x, this was indeed possible: Matplotlib was patched for
the figures to be dockable. In these old releases, Spyder's main
console (called the 'internal console' in v2.x) was running in the
same process as Spyder's main window. As it was running in the same
thread too (otherwise *no* GUI objects -like Matplotlib figures for
example- could have been created within this console), a simple
infinite loop was enough to crash Spyder.

This lack of safety was not acceptable, that's why I switched from an
internal console design (Spyder and its console are running in the
same thread/process) to an external console design (Spyder and its
console are running in two separate processes). This major change of
design was introduced progressively (since v1.0 actually) with the
'External console' being available together with the 'Console' in
Spyder v1.x. Now the v1.x's Console has been renamed to 'Internal
console' and is hidden by default (main purpose: internal debugging)
and the v1.x's external console has been renamed to 'Console' and is
the main console in which as many Python/IPython interpreters and
terminals (Windows-only) may be opened.

So, in Spyder v2.x, Matplotlib figures are no longer dockable because
they are created in another process so they absolutely do not relate
with Spyder's main window. That is the only feature that was
sacrificed when switching from the single process design to the two-
process design.

Technically, this would be possible but it would require a lot of
programming to patch Matplotlib so that it could be called remotely:
figures would be created in Spyder main window's process directly from
the remote process (Console) - this would require to send data over
the process-to-process connection (a BSD socket) which may be slow
down things a little bit when dealing with very large amount of data
(> hundreds of MB).

Cheers,
Pierre

bgbg.bg

unread,
Dec 14, 2010, 2:53:33 AM12/14/10
to spyd...@googlegroups.com
Thank you, Pierre for the answer AND for the wonderful tool

marmaduke

unread,
Jan 14, 2011, 5:41:14 AM1/14/11
to spyd...@googlegroups.com

Would it be possible to have the external thread render the image, use savefig() to pipe the image to the main process or a file on disk, and display the rendered image in the main Spyder window?

If Spyder's main process monitors the workspace of IPython, then a push_fig_to_spyder() function could register a new or updated figure in a special workspace variable.

This, of course, wouldn't be satisfying for interactive figures, but if the concern is just to avoid external windows, it might be enough.

David Verelst

unread,
Jan 15, 2011, 6:35:28 AM1/15/11
to spyd...@googlegroups.com
In danger of taken that topic a bit too far...

What I haven't found for matplotlib yet is a figure format like .fig in Matlab:
* saving the figure data with numpy.save, pickle or pytables (hdf5)
* save the actual plotting commands, so you render the image again when opening
* have a docked spyder window re-render whatever image you saved before

But maybe this is more of a topic for the matplotlib mailing list.

David

> --
> You received this message because you are subscribed to the Google Groups
> "spyder" group.
> To post to this group, send email to spyd...@googlegroups.com.
> To unsubscribe from this group, send email to
> spyderlib+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/spyderlib?hl=en.
>

Pierre Raybaut

unread,
Jan 15, 2011, 7:55:39 AM1/15/11
to spyder
Exactly, that's the way I would do it if I had to. I really don't know
if Matplotlib objects could be made easily picklable. But I know that
most of the guiqwt objects are picklable so this method should be
relatively easy to implement (but guiqwt plotting type collection is
very poor when compared to Matplotlib's - that is not the main purpose
of guiqwt).

Anyway, there is something to dig for recreating the v1.x dockable
Matplotlib figures.

On Jan 15, 12:35 pm, David Verelst <david.vere...@gmail.com> wrote:
> In danger of taken that topic a bit too far...
>
> What I haven't found for matplotlib yet is a figure format like .fig in Matlab:
> * saving the figure data with numpy.save, pickle or pytables (hdf5)
> * save the actual plotting commands, so you render the image again when opening
> * have a docked spyder window re-render whatever image you saved before
>
> But maybe this is more of a topic for the matplotlib mailing list.
>
> David
>
Reply all
Reply to author
Forward
0 new messages