0

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])

enter image description here

Is there any way to update position of inset axes ?

Jiadong
  • 1,822
  • 1
  • 17
  • 37

1 Answers1

1

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)

enter image description here

r-beginners
  • 31,170
  • 3
  • 14
  • 32