Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6dd30a2

Browse files
committed
Add test for InsetPosition and correct example
1 parent 5c45952 commit 6dd30a2

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

lib/mpl_toolkits/axes_grid1/inset_locator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(self, parent, lbwh):
4343
4444
>>> parent_axes = plt.gca()
4545
>>> ax_ins = plt.axes([0, 0, 1, 1])
46-
>>> ip = InsetPosition(ax, [0.5, 0.1, 0.4, 0.2])
46+
>>> ip = InsetPosition(parent_axes, [0.5, 0.1, 0.4, 0.2])
4747
>>> ax_ins.set_axes_locator(ip)
4848
"""
4949
self.parent = parent

lib/mpl_toolkits/tests/test_axes_grid1.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
Divider, HBoxDivider, make_axes_area_auto_adjustable)
2222
from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes
2323
from mpl_toolkits.axes_grid1.inset_locator import (
24-
zoomed_inset_axes, mark_inset, inset_axes, BboxConnectorPatch)
24+
zoomed_inset_axes, mark_inset, inset_axes, BboxConnectorPatch,
25+
InsetPosition)
2526
import mpl_toolkits.axes_grid1.mpl_axes
2627

2728
import pytest
@@ -571,6 +572,14 @@ def test_rgb_axes():
571572
ax.imshow_rgb(r, g, b, interpolation='none')
572573

573574

575+
@image_comparison(['insetposition.png'], remove_text=True)
576+
def test_insetposition():
577+
fig, ax = plt.subplots(figsize=(2, 2))
578+
ax_ins = plt.axes([0, 0, 1, 1])
579+
ip = InsetPosition(ax, [0.2, 0.25, 0.5, 0.4])
580+
ax_ins.set_axes_locator(ip)
581+
582+
574583
# The original version of this test relied on mpl_toolkits's slightly different
575584
# colorbar implementation; moving to matplotlib's own colorbar implementation
576585
# caused the small image comparison error.

0 commit comments

Comments
 (0)