Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed as not planned
Closed as not planned
Labels
Description
Bug summary
An inset axes created usingmpl_toolkits.axes_grid1.inset_locator.inset_axes
seems to inherit its position from the parent axes. This prevents any connection lines being drawn byindicate_inset_zoom
showing up, astheir "visible" attributes depend on the result of get_position.
Code for reproduction
# Adapted from the gallery example, but replacing the axes method with the function from toolkits.frommatplotlibimportcbookimportmatplotlib.pyplotaspltfrommpl_toolkits.axes_grid1.inset_locatorimportinset_axesimportnumpyasnpdefget_demo_image():z=cbook.get_sample_data("axes_grid/bivariate_normal.npy",np_load=True)# z is a numpy array of 15x15returnz, (-3,4,-4,3)fig,ax=plt.subplots(figsize=[5,4])# make dataZ,extent=get_demo_image()Z2=np.zeros((150,150))ny,nx=Z.shapeZ2[30:30+ny,30:30+nx]=Zax.imshow(Z2,extent=extent,origin="lower")# inset axes....axins=inset_axes(ax,width="50%",height="50%")axins.imshow(Z2,extent=extent,origin="lower")# sub region of the original imagex1,x2,y1,y2=-1.5,-0.9,-2.5,-1.9axins.set_xlim(x1,x2)axins.set_ylim(y1,y2)axins.set_xticklabels([])axins.set_yticklabels([])print("main axes position:",ax.get_position())print("inset axes position:",axins.get_position())ax.indicate_inset_zoom(axins,edgecolor="black")plt.show()
Actual outcome
main axes position: Bbox(x0=0.20449999999999996, y0=0.10999999999999999, x1=0.8205, y1=0.88)inset axes position: Bbox(x0=0.20449999999999996, y0=0.10999999999999999, x1=0.8205, y1=0.88)
Expected outcome
Plot should have connecting lines, similar to thezoom region inset axes gallery example.
Additional information
No response
Operating system
RHEL
Matplotlib Version
3.5.1
Matplotlib Backend
TKAgg
Python version
3.10.2
Jupyter version
No response
Installation
conda