From e767003d9662865cb1aa2a4efed1f84f709f2032 Mon Sep 17 00:00:00 2001 From: stonebig Date: Tue, 27 Feb 2018 23:03:15 +0100 Subject: [PATCH 1/5] make seaborn great again on Matplotlib-2.2 fix for https://github.com/matplotlib/matplotlib/issues/10585 --- lib/matplotlib/axes/_subplots.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/axes/_subplots.py b/lib/matplotlib/axes/_subplots.py index fd3754e7ea53..593e5b7677fa 100644 --- a/lib/matplotlib/axes/_subplots.py +++ b/lib/matplotlib/axes/_subplots.py @@ -172,8 +172,8 @@ def _make_twin_axes(self, *kl, **kwargs): Make a twinx axes of self. This is used for twinx and twiny. """ from matplotlib.projections import process_projection_requirements - if 'sharex' in kwargs and 'sharey' in kwargs: - raise ValueError("Twinned Axes may share only one axis.") + if kwargs["sharex"] is not self and kwargs["sharey"] is not self: + raise ValueError("Twinned Axes may share only one axis.") kl = (self.get_subplotspec(),) + kl projection_class, kwargs, key = process_projection_requirements( self.figure, *kl, **kwargs) From 2c37e60f69c3006168b13f417d971acae950a0f5 Mon Sep 17 00:00:00 2001 From: stonebig Date: Tue, 27 Feb 2018 23:04:17 +0100 Subject: [PATCH 2/5] pep8 --- lib/matplotlib/axes/_subplots.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/axes/_subplots.py b/lib/matplotlib/axes/_subplots.py index 593e5b7677fa..f09b184922b9 100644 --- a/lib/matplotlib/axes/_subplots.py +++ b/lib/matplotlib/axes/_subplots.py @@ -173,7 +173,7 @@ def _make_twin_axes(self, *kl, **kwargs): """ from matplotlib.projections import process_projection_requirements if kwargs["sharex"] is not self and kwargs["sharey"] is not self: - raise ValueError("Twinned Axes may share only one axis.") + raise ValueError("Twinned Axes may share only one axis.") kl = (self.get_subplotspec(),) + kl projection_class, kwargs, key = process_projection_requirements( self.figure, *kl, **kwargs) From a736720d58cf55b283c550880a7b981137d9b17b Mon Sep 17 00:00:00 2001 From: stonebig Date: Tue, 27 Feb 2018 23:39:49 +0100 Subject: [PATCH 3/5] test like before, but allowing seaborn exception --- lib/matplotlib/axes/_subplots.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/axes/_subplots.py b/lib/matplotlib/axes/_subplots.py index f09b184922b9..0c25c0531630 100644 --- a/lib/matplotlib/axes/_subplots.py +++ b/lib/matplotlib/axes/_subplots.py @@ -172,8 +172,9 @@ def _make_twin_axes(self, *kl, **kwargs): Make a twinx axes of self. This is used for twinx and twiny. """ from matplotlib.projections import process_projection_requirements - if kwargs["sharex"] is not self and kwargs["sharey"] is not self: - raise ValueError("Twinned Axes may share only one axis.") + if 'sharex' in kwargs and 'sharey' in kwargs: + if kwargs["sharex"] is not self and kwargs["sharey"] is not self: + raise ValueError("Twinned Axes may share only one axis.") kl = (self.get_subplotspec(),) + kl projection_class, kwargs, key = process_projection_requirements( self.figure, *kl, **kwargs) From 466330b89c955647577ce71697f4b05ec2d38004 Mon Sep 17 00:00:00 2001 From: stonebig Date: Wed, 28 Feb 2018 22:45:54 +0100 Subject: [PATCH 4/5] document the reason for the change --- lib/matplotlib/axes/_subplots.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/matplotlib/axes/_subplots.py b/lib/matplotlib/axes/_subplots.py index 0c25c0531630..1bcbdd98c0cb 100644 --- a/lib/matplotlib/axes/_subplots.py +++ b/lib/matplotlib/axes/_subplots.py @@ -173,6 +173,8 @@ def _make_twin_axes(self, *kl, **kwargs): """ from matplotlib.projections import process_projection_requirements if 'sharex' in kwargs and 'sharey' in kwargs: + # The following line is added in v2.2 to avoid breaking Seaborn, + # which currently uses this internal API. if kwargs["sharex"] is not self and kwargs["sharey"] is not self: raise ValueError("Twinned Axes may share only one axis.") kl = (self.get_subplotspec(),) + kl From 09a17f4b9257410b0740722db78445dbcbad8abd Mon Sep 17 00:00:00 2001 From: stonebig Date: Wed, 28 Feb 2018 23:41:35 +0100 Subject: [PATCH 5/5] pep8 remove trailing spaces on a comment line --- lib/matplotlib/axes/_subplots.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/axes/_subplots.py b/lib/matplotlib/axes/_subplots.py index 1bcbdd98c0cb..4c93ed996a16 100644 --- a/lib/matplotlib/axes/_subplots.py +++ b/lib/matplotlib/axes/_subplots.py @@ -174,7 +174,7 @@ def _make_twin_axes(self, *kl, **kwargs): from matplotlib.projections import process_projection_requirements if 'sharex' in kwargs and 'sharey' in kwargs: # The following line is added in v2.2 to avoid breaking Seaborn, - # which currently uses this internal API. + # which currently uses this internal API. if kwargs["sharex"] is not self and kwargs["sharey"] is not self: raise ValueError("Twinned Axes may share only one axis.") kl = (self.get_subplotspec(),) + kl