()
| 9764 | |
| 9765 | @image_comparison(["extent_units.png"], style="mpl20") |
| 9766 | def test_extent_units(): |
| 9767 | _, axs = plt.subplots(2, 2) |
| 9768 | date_first = np.datetime64('2020-01-01', 'D') |
| 9769 | date_last = np.datetime64('2020-01-11', 'D') |
| 9770 | arr = [[i+j for i in range(10)] for j in range(10)] |
| 9771 | |
| 9772 | axs[0, 0].set_title('Date extents on y axis') |
| 9773 | im = axs[0, 0].imshow(arr, origin='lower', |
| 9774 | extent=[1, 11, date_first, date_last], |
| 9775 | cmap=mpl.colormaps["plasma"]) |
| 9776 | |
| 9777 | axs[0, 1].set_title('Date extents on x axis (Day of Jan 2020)') |
| 9778 | im = axs[0, 1].imshow(arr, origin='lower', |
| 9779 | extent=[date_first, date_last, 1, 11], |
| 9780 | cmap=mpl.colormaps["plasma"]) |
| 9781 | axs[0, 1].xaxis.set_major_formatter(mdates.DateFormatter('%d')) |
| 9782 | |
| 9783 | im = axs[1, 0].imshow(arr, origin='lower', |
| 9784 | extent=[date_first, date_last, |
| 9785 | date_first, date_last], |
| 9786 | cmap=mpl.colormaps["plasma"]) |
| 9787 | axs[1, 0].xaxis.set_major_formatter(mdates.DateFormatter('%d')) |
| 9788 | axs[1, 0].set(xlabel='Day of Jan 2020') |
| 9789 | |
| 9790 | im = axs[1, 1].imshow(arr, origin='lower', |
| 9791 | cmap=mpl.colormaps["plasma"]) |
| 9792 | im.set_extent([date_last, date_first, date_last, date_first]) |
| 9793 | axs[1, 1].xaxis.set_major_formatter(mdates.DateFormatter('%d')) |
| 9794 | axs[1, 1].set(xlabel='Day of Jan 2020') |
| 9795 | |
| 9796 | with pytest.raises(TypeError, match=r"set_extent\(\) got an unexpected"): |
| 9797 | im.set_extent([2, 12, date_first, date_last], clip=False) |
| 9798 | |
| 9799 | |
| 9800 | def test_cla_clears_children_axes_and_fig(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…