Hi,
I have a previously draw plot that I want to place as an inset in
another figure. I've tried with passing the previously drawn axes as
the `axes` parameter to the `add_axes` method of the figure, and also
tried using the `set_axes` method of the new axes, without success: I
get the new inset axes, but without the previously drawn plot, in both
cases.
The following code shows both approaches:
# Passing the inset axes as a parameter to add_axes
fig_in, ax_in = plt.subplots()
ax_in.plot([1,2,3])
fig, ax = plt.subplots()
ax.plot([1,2,1])
fig.add_axes([0.72, 0.72, 0.16, 0.16], axes=ax_in)
# Using set_axes
fig_in, ax_in = plt.subplots()
ax_in.plot([1,2,3])
fig, ax = plt.subplots()
ax.plot([1,2,1])
ax_new = fig.add_axes([0.72, 0.72, 0.16, 0.16])
ax_new.set_axes(ax_in)
Any help with this will be appreciated.
Regards,
Alejandro
An axes can only belong to one figure at a time. And I also don’t think I have ever seen anyone try and transfer an axes from one figure to another.
You might have luck with inset locators from axes_grid: http://matplotlib.org/examples/axes_grid/inset_locator_demo.html
Cheers!
Ben Root
···
On Thu, Oct 29, 2015 at 12:07 PM, Alejandro Weinstein <alejandro.weinstein@…2015…87…> wrote:
Hi,
I have a previously draw plot that I want to place as an inset in
another figure. I’ve tried with passing the previously drawn axes as
the axes
parameter to the add_axes
method of the figure, and also
tried using the set_axes
method of the new axes, without success: I
get the new inset axes, but without the previously drawn plot, in both
cases.
The following code shows both approaches:
# Passing the inset axes as a parameter to add_axes
fig_in, ax_in = plt.subplots()
ax_in.plot([1,2,3])
fig, ax = plt.subplots()
ax.plot([1,2,1])
fig.add_axes([0.72, 0.72, 0.16, 0.16], axes=ax_in)
# Using set_axes
fig_in, ax_in = plt.subplots()
ax_in.plot([1,2,3])
fig, ax = plt.subplots()
ax.plot([1,2,1])
ax_new = fig.add_axes([0.72, 0.72, 0.16, 0.16])
ax_new.set_axes(ax_in)
Any help with this will be appreciated.
Regards,
Alejandro
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users