diff --git a/lib/matplotlib/path.py b/lib/matplotlib/path.py index b2540be1c18f..0749703cb339 100644 --- a/lib/matplotlib/path.py +++ b/lib/matplotlib/path.py @@ -172,7 +172,7 @@ def _fast_from_codes_and_verts(cls, verts, codes, internals=None): Parameters ---------- verts : numpy array - codes : numpy array (may not be None) + codes : numpy array internals : dict or None The attributes that the resulting path should have. Allowed keys are ``readonly``, ``should_simplify``, diff --git a/lib/matplotlib/tests/baseline_images/test_path/semi_log_with_zero.png b/lib/matplotlib/tests/baseline_images/test_path/semi_log_with_zero.png new file mode 100644 index 000000000000..8edfb8a0a64b Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_path/semi_log_with_zero.png differ diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index c664d746865d..be16a8cd8b56 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -3473,18 +3473,21 @@ def test_pathological_hexbin(): fig.savefig(out) assert_equal(len(w), 0) + @cleanup def test_color_None(): # issue 3855 fig, ax = plt.subplots() - ax.plot([1,2], [1,2], color=None) + ax.plot([1, 2], [1, 2], color=None) plt.show() + @cleanup def test_numerical_hist_label(): fig, ax = plt.subplots() ax.hist([range(15)] * 5, label=range(5)) + if __name__ == '__main__': import nose import sys diff --git a/lib/matplotlib/tests/test_path.py b/lib/matplotlib/tests/test_path.py index 3d0c56bd5d43..b1e1f2307e16 100644 --- a/lib/matplotlib/tests/test_path.py +++ b/lib/matplotlib/tests/test_path.py @@ -72,6 +72,17 @@ def test_point_in_path_nan(): assert not contains[0] +@image_comparison(baseline_images=['semi_log_with_zero'], extensions=['png']) +def test_log_transform_with_zero(): + x = np.arange(-10, 10) + y = (1.0 - 1.0/(x**2+1))**20 + + fig, ax = plt.subplots() + ax.semilogy(x, y, "-o", lw=15) + ax.grid(True) + plt.show() + + if __name__ == '__main__': import nose nose.runmodule(argv=['-s', '--with-doctest'], exit=False) diff --git a/lib/matplotlib/transforms.py b/lib/matplotlib/transforms.py index 0c7a48cbf7c7..afaf9f2eb835 100644 --- a/lib/matplotlib/transforms.py +++ b/lib/matplotlib/transforms.py @@ -1300,7 +1300,7 @@ def transform(self, values): # Convert the result back to the shape of the input values. if ndim == 0: - assert not np.ma.is_masked(res) # just to be on the safe side + assert not np.ma.is_masked(res) # just to be on the safe side return res[0, 0] if ndim == 1: return res.reshape(-1) @@ -1412,6 +1412,8 @@ def transform_path_non_affine(self, path): ``transform_path_affine(transform_path_non_affine(values))``. """ x = self.transform_non_affine(path.vertices) + if ma.isMaskedArray(x): + x = x.astype(np.float_).filled(np.nan) return Path._fast_from_codes_and_verts(x, path.codes, {'interpolation_steps': path._interpolation_steps}) @@ -2613,14 +2615,25 @@ def __init__(self, path, transform): self._transformed_points = None def _revalidate(self): - # only recompute if the invalidation includes the non_affine part of the transform - if ((self._invalid & self.INVALID_NON_AFFINE == self.INVALID_NON_AFFINE) - or self._transformed_path is None): - self._transformed_path = \ - self._transform.transform_path_non_affine(self._path) - self._transformed_points = \ - Path._fast_from_codes_and_verts(self._transform.transform_non_affine(self._path.vertices), - None, {'interpolation_steps': self._path._interpolation_steps}) + # only recompute if the invalidation includes + # the non_affine part of the transform + if ((self._invalid & + self.INVALID_NON_AFFINE == self.INVALID_NON_AFFINE) + or self._transformed_path is None): + + tpath = self._transform.transform_path_non_affine(self._path) + self._transformed_path = tpath + + x = self._transform.transform_non_affine(self._path.vertices) + if ma.isMaskedArray(x): + x = x.astype(np.float_).filled(np.nan) + + tpts = Path._fast_from_codes_and_verts(verts=x, codes=None, + internals={'interpolation_steps': + self._path._interpolation_steps}) + + self._transformed_points = tpts + self._invalid = 0 def get_transformed_points_and_affine(self):