|
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 ( |
@@ -2545,8 +2548,6 @@ def get_next_color(): |
2545 | 2548 |
|
2546 | 2549 | def test_as_mpl_axes_api(): |
2547 | 2550 | # tests the _as_mpl_axes api |
2548 | | - from matplotlib.projections.polar import PolarAxes |
2549 | | - |
2550 | 2551 | class Polar: |
2551 | 2552 | def __init__(self): |
2552 | 2553 | self.theta_offset = 0 |
@@ -6625,6 +6626,31 @@ def test_zoom_inset(): |
6625 | 6626 | axin1.get_position().get_points(), xx, rtol=1e-4) |
6626 | 6627 |
|
6627 | 6628 |
|
| 6629 | +@image_comparison(['inset_polar.png'], remove_text=True, style='mpl20') |
| 6630 | +def test_inset_polar(): |
| 6631 | + _, ax = plt.subplots() |
| 6632 | + axins = ax.inset_axes([0.5, 0.1, 0.45, 0.45], polar=True) |
| 6633 | + assert isinstance(axins, PolarAxes) |
| 6634 | + |
| 6635 | + r = np.arange(0, 2, 0.01) |
| 6636 | + theta = 2 * np.pi * r |
| 6637 | + |
| 6638 | + ax.plot(theta, r) |
| 6639 | + axins.plot(theta, r) |
| 6640 | + |
| 6641 | + |
| 6642 | +def test_inset_projection(): |
| 6643 | + _, ax = plt.subplots() |
| 6644 | + axins = ax.inset_axes([0.2, 0.2, 0.3, 0.3], projection="hammer") |
| 6645 | + assert isinstance(axins, HammerAxes) |
| 6646 | + |
| 6647 | + |
| 6648 | +def test_inset_subclass(): |
| 6649 | + _, ax = plt.subplots() |
| 6650 | + axins = ax.inset_axes([0.2, 0.2, 0.3, 0.3], axes_class=AA.Axes) |
| 6651 | + assert isinstance(axins, AA.Axes) |
| 6652 | + |
| 6653 | + |
6628 | 6654 | @pytest.mark.parametrize('x_inverted', [False, True]) |
6629 | 6655 | @pytest.mark.parametrize('y_inverted', [False, True]) |
6630 | 6656 | def test_indicate_inset_inverted(x_inverted, y_inverted): |
|
0 commit comments