|
26 | 26 | import matplotlib.markers as mmarkers |
27 | 27 | import matplotlib.patches as mpatches |
28 | 28 | import matplotlib.path as mpath |
| 29 | +from matplotlib.projections.geo import HammerAxes |
| 30 | +from matplotlib.projections.polar import PolarAxes |
29 | 31 | import matplotlib.pyplot as plt |
30 | 32 | import matplotlib.text as mtext |
31 | 33 | import matplotlib.ticker as mticker |
32 | 34 | import matplotlib.transforms as mtransforms |
| 35 | +import mpl_toolkits.axisartist as AA |
33 | 36 | from numpy.testing import ( |
34 | 37 | assert_allclose, assert_array_equal, assert_array_almost_equal) |
35 | 38 | from matplotlib.testing.decorators import ( |
@@ -2543,8 +2546,6 @@ def get_next_color(): |
2543 | 2546 |
|
2544 | 2547 | def test_as_mpl_axes_api(): |
2545 | 2548 | # tests the _as_mpl_axes api |
2546 | | - from matplotlib.projections.polar import PolarAxes |
2547 | | - |
2548 | 2549 | class Polar: |
2549 | 2550 | def __init__(self): |
2550 | 2551 | self.theta_offset = 0 |
@@ -6614,6 +6615,31 @@ def test_zoom_inset(): |
6614 | 6615 | axin1.get_position().get_points(), xx, rtol=1e-4) |
6615 | 6616 |
|
6616 | 6617 |
|
| 6618 | +@image_comparison(['inset_polar.png'], remove_text=True, style='mpl20') |
| 6619 | +def test_inset_polar(): |
| 6620 | + _, ax = plt.subplots() |
| 6621 | + axins = ax.inset_axes([0.5, 0.1, 0.45, 0.45], polar=True) |
| 6622 | + assert isinstance(axins, PolarAxes) |
| 6623 | + |
| 6624 | + r = np.arange(0, 2, 0.01) |
| 6625 | + theta = 2 * np.pi * r |
| 6626 | + |
| 6627 | + ax.plot(theta, r) |
| 6628 | + axins.plot(theta, r) |
| 6629 | + |
| 6630 | + |
| 6631 | +def test_inset_projection(): |
| 6632 | + _, ax = plt.subplots() |
| 6633 | + axins = ax.inset_axes([0.2, 0.2, 0.3, 0.3], projection="hammer") |
| 6634 | + assert isinstance(axins, HammerAxes) |
| 6635 | + |
| 6636 | + |
| 6637 | +def test_inset_subclass(): |
| 6638 | + _, ax = plt.subplots() |
| 6639 | + axins = ax.inset_axes([0.2, 0.2, 0.3, 0.3], axes_class=AA.Axes) |
| 6640 | + assert isinstance(axins, AA.Axes) |
| 6641 | + |
| 6642 | + |
6617 | 6643 | @pytest.mark.parametrize('x_inverted', [False, True]) |
6618 | 6644 | @pytest.mark.parametrize('y_inverted', [False, True]) |
6619 | 6645 | def test_indicate_inset_inverted(x_inverted, y_inverted): |
|
0 commit comments