Move the content of a figure into a subplot of this figure.

Hi list,

I am trying to implement some GUI tools in matplotlib - more precisely a line profile tool and a contrast setter which I hope will be integrated to the skimage kit [see https://github.com/glyg/scikits-image/blob/master/skimage/io/_plugins/matplotlib_plugin.py].

Now here is my question:
Is it possible to grab the content of a figure and 'displace' it in a subplot of the same figure, to give room for a knew plot - even if the original content is complex (i.e. an image + a colorbar + an histogram, for example).

I am not sure I'm clear here, so I can try to rephrase if needed.

Thanks

Guillaume

Hi,

you should be able to do so. In the past, I had written a small GUI that
had the ability to copy Line2D, images and text elements from an axe to
any other axes (even on different figure). This was integrated into GUI
used to change the line properties. It is a bit old and dirty but you
can find it there:
http://mpl-properties.googlecode.com/svn/trunk/mpl_properties.py

look for the "do_copy" function.

Antoine

···

On Fri, 2012-03-02 at 11:57 +0100, Guillaume Gay wrote:

Hi list,

I am trying to implement some GUI tools in matplotlib - more precisely a
line profile tool and a contrast setter which I hope will be integrated
to the skimage kit [see
https://github.com/glyg/scikits-image/blob/master/skimage/io/_plugins/matplotlib_plugin.py].

Now here is my question:
Is it possible to grab the content of a figure and 'displace' it in a
subplot of the same figure, to give room for a knew plot - even if the
original content is complex (i.e. an image + a colorbar + an histogram,
for example).

I am not sure I'm clear here, so I can try to rephrase if needed.

Thanks

Guillaume
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users

I am not sure if you are trying to move objects from one axes to another or merely reposition an existing axes to make room for a new one.

Both are possible, but the latter is easy. Each axes has [left, bottom, width, height] rectangle in (0,1) figure coordinates that you can adjust at any time. See for example the subplots_adjust tool on the navigation toolbar next to the save icon

http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.set_position

If you are working with subplots, also see the change_geometry method

http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.SubplotBase.change_geometry

colorbars are a little tricky, because there you are needing to reposition two axes, one for the image, and one for the colorbar itself. You can do this manually, but you probably want to look at JJ’s gridspec and axes_grid tools for laying out groups of axes:

http://matplotlib.sourceforge.net/users/gridspec.html

http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/index.html#toolkit-axesgrid-index

JDH

···

On Fri, Mar 2, 2012 at 4:57 AM, Guillaume Gay <guillaume@…4007…> wrote:

Hi list,

I am trying to implement some GUI tools in matplotlib - more precisely a line profile tool and a contrast setter which I hope will be integrated to the skimage kit [see https://github.com/glyg/scikits-image/blob/master/skimage/io/_plugins/matplotlib_plugin.py].

Now here is my question:

Is it possible to grab the content of a figure and ‘displace’ it in a subplot of the same figure, to give room for a knew plot - even if the original content is complex (i.e. an image + a colorbar + an histogram, for example).

I am not sure I’m clear here, so I can try to rephrase if needed.