Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]: inset_axes position same as parent axes position. Breaks indicate_axes_zoom #22606

Closed as not planned
@rcomer

Description

@rcomer

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)

zoom_no_indicate

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp