Reputation: 2072
set_position()
seems not to work for inset axes in matploltib, see code below:
import matplotlib.pyplot as plt
fig, ax = plt.subplots(1, 1, figsize=(7.2, 7.2))
# make inset axes
axin = ax.inset_axes([0.1, 0.1, 0.2, 0.2])
# update position, NOT working
axin.set_position([0.2, 0.2, 0.2, 0.2])
Is there any way to update position of inset axes ?
Upvotes: 0
Views: 1106
Reputation: 35115
Here's a great answer. I saw this and modified your code. I don't have enough knowledge to explain this so please refer to his answer.
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import InsetPosition
fig, ax = plt.subplots(1, 1, figsize=(7.2, 7.2))
axin = ax.inset_axes([0.1, 0.1, 0.2, 0.2])
ip = InsetPosition(ax,[0.2, 0.2, 0.2, 0.2])
axin.set_axes_locator(ip)
Upvotes: 1