Be compatible with matplotlib 3.5
authorDebian Science Team <debian-science-maintainers@lists.alioth.debian.org>
Thu, 2 Dec 2021 16:32:54 +0000 (16:32 +0000)
committerJochen Sprickerhof <jspricke@debian.org>
Thu, 2 Dec 2021 16:32:54 +0000 (16:32 +0000)
Origin: upstream 63e323356eab4fd91e453a9855a97cbc210362ef
Author: Thomas Li, Simon Hawkins
Forwarded: not-needed

Gbp-Pq: Name matplotlib35_compat.patch

pandas/plotting/_matplotlib/compat.py
pandas/plotting/_matplotlib/converter.py
pandas/plotting/_matplotlib/core.py
pandas/tests/plotting/common.py
pandas/tests/plotting/frame/test_frame.py
pandas/tests/plotting/test_common.py
pandas/tests/plotting/test_hist_method.py
pandas/tests/plotting/test_series.py

index 70ddd1ca09c7e90ec5534028cf15a1ef149244b3..5569b1f2979b0f028236d7184b67c03ecb4a7386 100644 (file)
@@ -24,3 +24,4 @@ mpl_ge_3_1_0 = _mpl_version("3.1.0", operator.ge)
 mpl_ge_3_2_0 = _mpl_version("3.2.0", operator.ge)
 mpl_ge_3_3_0 = _mpl_version("3.3.0", operator.ge)
 mpl_ge_3_4_0 = _mpl_version("3.4.0", operator.ge)
+mpl_ge_3_5_0 = _mpl_version("3.5.0", operator.ge)
index 7e3bf0b224e0eac4be7ea97b4065152d0d9caca6..5fcd61f2b4f110a60eeab2899e46c2cd53ed553d 100644 (file)
@@ -353,8 +353,8 @@ class PandasAutoDateLocator(dates.AutoDateLocator):
             locator = MilliSecondLocator(self.tz)
             locator.set_axis(self.axis)
 
-            locator.set_view_interval(*self.axis.get_view_interval())
-            locator.set_data_interval(*self.axis.get_data_interval())
+            locator.axis.set_view_interval(*self.axis.get_view_interval())
+            locator.axis.set_data_interval(*self.axis.get_data_interval())
             return locator
 
         return dates.AutoDateLocator.get_locator(self, dmin, dmax)
index 7ddab91a24ec0f556770e5137a30ad893a5e4818..dbdfff8e27b971449c4913b5482cb7737323eb3f 100644 (file)
@@ -983,6 +983,7 @@ class PlanePlot(MPLPlot):
         # use the last one which contains the latest information
         # about the ax
         img = ax.collections[-1]
+        ax.grid(False)
         cbar = self.fig.colorbar(img, ax=ax, **kwds)
 
         if mpl_ge_3_0_0():
index e2b6b5ab3319c9bdfa5158bfa20461ff2663c027..52127b926f1fae5aec1d5c29141d771c0ad0767c 100644 (file)
@@ -45,6 +45,8 @@ class TestPlotBase:
 
         from pandas.plotting._matplotlib import compat
 
+        self.compat = compat
+
         mpl.rcdefaults()
 
         self.start_date_to_int64 = 812419200000000000
@@ -569,6 +571,12 @@ class TestPlotBase:
         """
         return [v[field] for v in rcParams["axes.prop_cycle"]]
 
+    def get_x_axis(self, ax):
+        return ax._shared_axes["x"] if self.compat.mpl_ge_3_5_0() else ax._shared_x_axes
+
+    def get_y_axis(self, ax):
+        return ax._shared_axes["y"] if self.compat.mpl_ge_3_5_0() else ax._shared_y_axes
+
 
 def _check_plot_works(f, filterwarnings="always", default_axes=False, **kwargs):
     """
index ccd0bc3d1689683bbbdaebd18ca74eeba11fc01d..6c07366e402d6c7c1cec37606c0cf1e10d1c27bb 100644 (file)
@@ -525,8 +525,8 @@ class TestDataFramePlots(TestPlotBase):
         df.plot(ax=ax1, kind="area")
         df.plot(ax=ax2, kind="area")
 
-        assert ax1._shared_y_axes.joined(ax1, ax2)
-        assert ax2._shared_y_axes.joined(ax1, ax2)
+        assert self.get_y_axis(ax1).joined(ax1, ax2)
+        assert self.get_y_axis(ax2).joined(ax1, ax2)
 
     def test_bar_linewidth(self):
         df = DataFrame(np.random.randn(5, 5))
index 4674fc1bb2c184fde67f2e597217874b36a0d31f..6eebf0c01ae52292bb92aa58af2c91c576375284 100644 (file)
@@ -39,4 +39,6 @@ class TestCommon(TestPlotBase):
         next(gen)
         axes = fig.get_axes()
         assert len(axes) == 1
-        assert axes[0].get_geometry() == (2, 1, 2)
+        subplot_geometry = list(axes[0].get_subplotspec().get_geometry()[:-1])
+        subplot_geometry[-1] += 1
+        assert subplot_geometry == [2, 1, 2]
index 96fdcebc9b8f72c9f21b333f3848c89b9f5a300d..403f4a2c06df1cf682670defd9daf37c1ddc0582 100644 (file)
@@ -728,35 +728,35 @@ class TestDataFrameGroupByPlots(TestPlotBase):
         ax1, ax2 = df.hist(column="height", by=df.gender, sharex=True)
 
         # share x
-        assert ax1._shared_x_axes.joined(ax1, ax2)
-        assert ax2._shared_x_axes.joined(ax1, ax2)
+        assert self.get_x_axis(ax1).joined(ax1, ax2)
+        assert self.get_x_axis(ax2).joined(ax1, ax2)
 
         # don't share y
-        assert not ax1._shared_y_axes.joined(ax1, ax2)
-        assert not ax2._shared_y_axes.joined(ax1, ax2)
+        assert not self.get_y_axis(ax1).joined(ax1, ax2)
+        assert not self.get_y_axis(ax2).joined(ax1, ax2)
 
     def test_axis_share_y(self):
         df = self.hist_df
         ax1, ax2 = df.hist(column="height", by=df.gender, sharey=True)
 
         # share y
-        assert ax1._shared_y_axes.joined(ax1, ax2)
-        assert ax2._shared_y_axes.joined(ax1, ax2)
+        assert self.get_y_axis(ax1).joined(ax1, ax2)
+        assert self.get_y_axis(ax2).joined(ax1, ax2)
 
         # don't share x
-        assert not ax1._shared_x_axes.joined(ax1, ax2)
-        assert not ax2._shared_x_axes.joined(ax1, ax2)
+        assert not self.get_x_axis(ax1).joined(ax1, ax2)
+        assert not self.get_x_axis(ax2).joined(ax1, ax2)
 
     def test_axis_share_xy(self):
         df = self.hist_df
         ax1, ax2 = df.hist(column="height", by=df.gender, sharex=True, sharey=True)
 
         # share both x and y
-        assert ax1._shared_x_axes.joined(ax1, ax2)
-        assert ax2._shared_x_axes.joined(ax1, ax2)
+        assert self.get_x_axis(ax1).joined(ax1, ax2)
+        assert self.get_x_axis(ax2).joined(ax1, ax2)
 
-        assert ax1._shared_y_axes.joined(ax1, ax2)
-        assert ax2._shared_y_axes.joined(ax1, ax2)
+        assert self.get_y_axis(ax1).joined(ax1, ax2)
+        assert self.get_y_axis(ax2).joined(ax1, ax2)
 
     @pytest.mark.parametrize(
         "histtype, expected",
index 812aae8d97151ee710fd681576d53be2f841ec2d..e40798f4f512582bccfaac12bd49eea72eb28f72 100644 (file)
@@ -154,8 +154,8 @@ class TestSeriesPlots(TestPlotBase):
         abs(self.ts).plot(ax=ax1, kind="area")
         abs(self.ts).plot(ax=ax2, kind="area")
 
-        assert ax1._shared_y_axes.joined(ax1, ax2)
-        assert ax2._shared_y_axes.joined(ax1, ax2)
+        assert self.get_y_axis(ax1).joined(ax1, ax2)
+        assert self.get_y_axis(ax2).joined(ax1, ax2)
 
     def test_label(self):
         s = Series([1, 2])