-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Description
Bug summary
Setting the position is an inset axes using the set_position method that is available for the inset axes doesn't change the position of the inset axes.
Code for reproduction
import numpy as np
from matplotlib import cbook
from matplotlib import pyplot as plt
import threading
fig, ax = plt.subplots()
# make data
Z = cbook.get_sample_data("axes_grid/bivariate_normal.npy") # 15x15 array
Z2 = np.zeros((150, 150))
ny, nx = Z.shape
Z2[30:30+ny, 30:30+nx] = Z
extent = (-3, 4, -4, 3)
ax.imshow(Z2, extent=extent, origin="lower")
# inset Axes....
x1, x2, y1, y2 = -1.5, -0.9, -2.5, -1.9 # subregion of the original image
axins = ax.inset_axes(
[0.75, 0.25, 0.25, 0.25],
xlim=(x1, x2), ylim=(y1, y2), xticklabels=[], yticklabels=[])
axins.imshow(Z2, extent=extent, origin="lower")
ax.indicate_inset_zoom(axins, edgecolor="black")
event = threading.Event()
import time
def do():
time.sleep(3)
print('setting position')
axins.set_position([0.45, 0.65, 0.50, 0.50])
fig.canvas.draw_idle()
t = threading.Thread(target=do)
t.daemon = True
t.start()
plt.show()Actual outcome
The inset axes doesn't move at all
Expected outcome
The inset axes should move when new position data is given to it.
Additional information
Maybe there is something that I am missing? I am doing an idle draw of the figure after I set the position, didn't make any difference.
Operating system
Windows 11
Matplotlib Version
3.10.7
Matplotlib Backend
tkagg & wxagg
Python version
3.11
Jupyter version
No response
Installation
pip