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

inset_locator.inset_axes produces axes without extent and at incorrect position. #8952

Closed
@ImportanceOfBeingErnest

Description

Thempl_toolkits.axes_grid1.inset_locator.inset_axes is not working as expected when using thebbox_to_anchor argument. Usinginset_axes(ax, width="70%", height="30%",bbox_to_anchor=(0.4,0.1), loc=3) gives an inset axes without extention at an incorrect position. (This issue is raised inthis stackoverflow post.)

Complete example:

import matplotlib.pyplot as pltfrom mpl_toolkits.axes_grid1.inset_locator import inset_axesplt.rcParams["figure.figsize"] = 4,3fig, ax= plt.subplots()iax =inset_axes(ax, width="70%", height="30%", bbox_to_anchor=(0.4,0.1), loc=3)iax.plot([1,2,4])plt.show()

gives

image

and a warning

c:\winpython\winpython-64bit-2.7.10.3\python-2.7.10.amd64\lib\site-packages\matplotlib\axis.py:1035: UserWarning: Unable to find pixel distance along axis for interval padding of ticks; assuming no interval padding needed.

when being run with python 2.7, matplotlib 2.0.2. In the lower left corner of the image you see what I suppose are the ticks of the zero-sized axes. Since the documentation clearly states thatwidth andheight can be strings (and they actually can be ifbbox_to_anchor is ommited) and since the defaultbbox_transform isparent_axes.transAxes, the above is clearly expected to work.

Note that when explicitely supplying thebbox_transform we at least get the axes at the correct position,

iax =inset_axes(ax, width="70%", height="30%", bbox_to_anchor=(0.4,0.1),                          loc=3, bbox_transform=ax.transAxes)

image

while width and height are further ignored.

Is this an error in the documentation or a bug in the matplotlib code?

Theexpected outcome of the above would be an inset axes with the lower left corner at (0.4,0.1) in axes coordinates and a width of 0.3 and a height of 0.7 (also in normalized axes units) as shown in the below image (which is produced by other means thaninset_axes):

image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp