« Return to Thread: Move the content of a figure into a subplot of this figure.

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

by John Hunter-4 :: Rate this Message:

| View in Thread



On Fri, Mar 2, 2012 at 4:57 AM, Guillaume Gay <guillaume@...> 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.


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

------------------------------------------------------------------------------
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@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

 « Return to Thread: Move the content of a figure into a subplot of this figure.