-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Closed
Labels
Milestone
Description
The docstring for mpl_toolkits.axes_grid1.zoomed_inset_axes indicates that the loc argument is:
loc : int or string, optional, default to 1
Location to place the inset axes. The valid locations are::
'upper right' : 1,
'upper left' : 2,
'lower left' : 3,
'lower right' : 4,
'right' : 5,
'center left' : 6,
'center right' : 7,
'lower center' : 8,
'upper center' : 9,
'center' : 10
However, editing examples/axes_grid1/inset_locator_demo.py as follows
- axins = zoomed_inset_axes(ax2, 0.5, loc=1) # zoom = 0.5
+ axins = zoomed_inset_axes(ax2, 0.5, loc="upper right") # zoom = 0.5
and running the example results in an AssertionError (which should probably also be replaced by a ValueError in any case...):
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/matplotlib/backends/backend_qt5agg.py", line 176, in __draw_idle_agg
FigureCanvasAgg.draw(self)
File "/usr/lib/python3.5/site-packages/matplotlib/backends/backend_agg.py", line 474, in draw
self.figure.draw(self.renderer)
File "/usr/lib/python3.5/site-packages/matplotlib/artist.py", line 61, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python3.5/site-packages/matplotlib/figure.py", line 1159, in draw
func(*args)
File "/usr/lib/python3.5/site-packages/mpl_toolkits/axes_grid1/parasite_axes.py", line 279, in draw
pos = locator(self, renderer)
File "/usr/lib/python3.5/site-packages/mpl_toolkits/axes_grid1/inset_locator.py", line 82, in __call__
px, py = self.get_offset(width, height, 0, 0, renderer)
File "/usr/lib/python3.5/site-packages/matplotlib/offsetbox.py", line 221, in get_offset
return self._offset(width, height, xdescent, ydescent, renderer)
File "/usr/lib/python3.5/site-packages/matplotlib/offsetbox.py", line 1145, in _offset
borderpad)
File "/usr/lib/python3.5/site-packages/matplotlib/offsetbox.py", line 1185, in _get_anchored_bbox
assert loc in range(1, 11) # called only internally
AssertionError
Python 3.5.1, tested on matplotlib 1.5.1 and on master.
As a minor note, I would simply rewrite the line as
axins = zoomed_inset_axes(ax2, zoom=0.5, loc="upper right")
which is more self-documenting.
Reactions are currently unavailable