From b5bc6aa85f466e2841ab6bcd8e4dce2cab5f28c6 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Tue, 17 Oct 2017 23:55:15 -0400 Subject: [PATCH] FIX: provide __ne__ implementation for transforms in py2 Closes #9455 The issue is that due to `!=` not defaulting to `not a == b` in python2 (unlike python3) an internal check was failing and the y ticks (aka the radial ticks) were being regenerated on every draw and the alpha settings did not properly propagate. This fix is a band-aid to make the behavior the same on all versions of python. --- lib/matplotlib/tests/test_axes.py | 16 ++++++++++++++++ lib/matplotlib/transforms.py | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 310baf41606c..ac98e926f8a4 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -5353,3 +5353,19 @@ def test_patch_deprecations(): assert fig.patch == fig.figurePatch assert len(w) == 2 + + +def test_polar_gridlines(): + fig = plt.figure() + ax = fig.add_subplot(111, polar=True) + + # make all major grid lines lighter, only x grid lines set in 2.1.0 + ax.grid(alpha=0.2) + + # hide y tick labels, no effect in 2.1.0 + plt.setp(ax.yaxis.get_ticklabels(), visible=False) + + fig.canvas.draw() + + assert ax.xaxis.majorTicks[0].gridline.get_alpha() == .2 + assert ax.yaxis.majorTicks[0].gridline.get_alpha() == .2 diff --git a/lib/matplotlib/transforms.py b/lib/matplotlib/transforms.py index 17049336e852..2269c9e40276 100644 --- a/lib/matplotlib/transforms.py +++ b/lib/matplotlib/transforms.py @@ -1287,6 +1287,10 @@ def __radd__(self, other): # override `__eq__`), but some subclasses, such as TransformWrapper & # AffineBase, override this behavior. + if six.PY2: + def __ne__(self, other): + return not (self == other) + def _iter_break_from_left_to_right(self): """ Returns an iterator breaking down this transform stack from left to