From 404e0ffd6376dbc6948284d4938c6368162760d1 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 15 May 2020 20:28:30 -0400 Subject: [PATCH 1/2] Backport PR #17422: Unstale viewlims before draw()ing polar axes. Merge pull request #17422 from anntzer/polarunstale Unstale viewlims before draw()ing polar axes. Conflicts: lib/matplotlib/projections/polar.py - conflicts from nearyby changes to signature of draw lib/matplotlib/tests/test_polar.py - tests are still in test_axes.py on v3.2.x --- lib/matplotlib/projections/polar.py | 1 + lib/matplotlib/tests/test_axes.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/projections/polar.py b/lib/matplotlib/projections/polar.py index 0f11abdbe119..06aa9be3ea44 100644 --- a/lib/matplotlib/projections/polar.py +++ b/lib/matplotlib/projections/polar.py @@ -953,6 +953,7 @@ def get_yaxis_text2_transform(self, pad): return self._yaxis_text_transform + pad_shift, 'center', halign def draw(self, *args, **kwargs): + self._unstale_viewLim() thetamin, thetamax = np.rad2deg(self._realViewLim.intervalx) if thetamin > thetamax: thetamin, thetamax = thetamax, thetamin diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 93548b2791ca..3ec602f84c4d 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -750,7 +750,11 @@ def test_polar_invertedylim(): def test_polar_invertedylim_rorigin(): fig = plt.figure() ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True) - ax.set_ylim(2, 0) + ax.yaxis.set_inverted(True) + # Set the rlims to inverted (2, 0) without calling set_rlim, to check that + # viewlims are correctly unstaled before draw()ing. + ax.plot([0, 0], [0, 2], c="none") + ax.margins(0) ax.set_rorigin(3) From 83f963a06677363e3f1b1fd88b52e18ba6c194e9 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sun, 17 May 2020 19:22:29 -0400 Subject: [PATCH 2/2] STY: remove unneeded fstring --- examples/statistics/confidence_ellipse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/statistics/confidence_ellipse.py b/examples/statistics/confidence_ellipse.py index 2db715237d57..ef26845886d3 100644 --- a/examples/statistics/confidence_ellipse.py +++ b/examples/statistics/confidence_ellipse.py @@ -217,7 +217,7 @@ def get_correlated_dataset(n, dependency, mu, scale): ax_kwargs.scatter(x, y, s=0.5) ax_kwargs.scatter(mu[0], mu[1], c='red', s=3) -ax_kwargs.set_title(f'Using kwargs') +ax_kwargs.set_title('Using kwargs') fig.subplots_adjust(hspace=0.25) plt.show()