Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
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
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)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):


