diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index 35308d7e9d4a..4acc66b4123d 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -1008,11 +1008,15 @@ def _update_ticks(self, renderer): except: warnings.warn("Unable to find pixel distance along axis for interval padding; assuming no interval padding needed.") ds1 = 0.0 + if np.isnan(ds1): + ds1 = 0.0 try: ds2 = self._get_pixel_distance_along_axis(interval_expanded[1], +0.5) except: warnings.warn("Unable to find pixel distance along axis for interval padding; assuming no interval padding needed.") ds2 = 0.0 + if np.isnan(ds2): + ds2 = 0.0 interval_expanded = (interval_expanded[0] - ds1, interval_expanded[1] + ds2) diff --git a/lib/matplotlib/tests/baseline_images/test_axes/mollweide_grid.pdf b/lib/matplotlib/tests/baseline_images/test_axes/mollweide_grid.pdf new file mode 100644 index 000000000000..c9306e718556 Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_axes/mollweide_grid.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_axes/mollweide_grid.png b/lib/matplotlib/tests/baseline_images/test_axes/mollweide_grid.png new file mode 100644 index 000000000000..fe566f77ee5e Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_axes/mollweide_grid.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_axes/mollweide_grid.svg b/lib/matplotlib/tests/baseline_images/test_axes/mollweide_grid.svg new file mode 100644 index 000000000000..f746856f65e1 --- /dev/null +++ b/lib/matplotlib/tests/baseline_images/test_axes/mollweide_grid.svg @@ -0,0 +1,1854 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index ad4b4c5c2a28..cec19b4d815a 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -1190,6 +1190,14 @@ def test_transparent_markers(): ax = fig.add_subplot(111) ax.plot(data, 'D', mfc='none', markersize=100) +@image_comparison(baseline_images=['mollweide_grid'], remove_text=True) +def test_mollweide_grid(): + # test that both horizontal and vertical gridlines appear on the Mollweide + # projection + fig = plt.figure() + ax = fig.add_subplot(111, projection='mollweide') + ax.grid() + @cleanup def test_mollweide_forward_inverse_closure(): # test that the round-trip Mollweide forward->inverse transformation is an