diff --git a/pandas/plotting/_matplotlib/misc.py b/pandas/plotting/_matplotlib/misc.py index a1c62f9fce23c..f519d1e96f5b0 100644 --- a/pandas/plotting/_matplotlib/misc.py +++ b/pandas/plotting/_matplotlib/misc.py @@ -144,7 +144,9 @@ def normalize(series): df = frame.drop(class_column, axis=1).apply(normalize) if ax is None: - ax = plt.gca(xlim=[-1, 1], ylim=[-1, 1]) + ax = plt.gca() + ax.set_xlim(-1, 1) + ax.set_ylim(-1, 1) to_plot: Dict[Label, List[List]] = {} colors = get_standard_colors( @@ -260,7 +262,8 @@ def f(t): ) colors = dict(zip(classes, color_values)) if ax is None: - ax = plt.gca(xlim=(-np.pi, np.pi)) + ax = plt.gca() + ax.set_xlim(-np.pi, np.pi) for i in range(n): row = df.iloc[i].values f = function(row) @@ -440,7 +443,9 @@ def autocorrelation_plot( n = len(series) data = np.asarray(series) if ax is None: - ax = plt.gca(xlim=(1, n), ylim=(-1.0, 1.0)) + ax = plt.gca() + ax.set_xlim(1, n) + ax.set_ylim(-1.0, 1.0) mean = np.mean(data) c0 = np.sum((data - mean) ** 2) / float(n) diff --git a/pandas/tests/plotting/test_misc.py b/pandas/tests/plotting/test_misc.py index 1208100ed2dce..ba774e8d13cf1 100644 --- a/pandas/tests/plotting/test_misc.py +++ b/pandas/tests/plotting/test_misc.py @@ -71,10 +71,12 @@ def setup_method(self, method): def test_autocorrelation_plot(self): from pandas.plotting import autocorrelation_plot - _check_plot_works(autocorrelation_plot, series=self.ts) - _check_plot_works(autocorrelation_plot, series=self.ts.values) + # Ensure no UserWarning when making plot + with tm.assert_produces_warning(None): + _check_plot_works(autocorrelation_plot, series=self.ts) + _check_plot_works(autocorrelation_plot, series=self.ts.values) - ax = autocorrelation_plot(self.ts, label="Test") + ax = autocorrelation_plot(self.ts, label="Test") self._check_legend_labels(ax, labels=["Test"]) def test_lag_plot(self): @@ -132,8 +134,9 @@ def test_andrews_curves(self, iris): from pandas.plotting import andrews_curves df = iris - - _check_plot_works(andrews_curves, frame=df, class_column="Name") + # Ensure no UserWarning when making plot + with tm.assert_produces_warning(None): + _check_plot_works(andrews_curves, frame=df, class_column="Name") rgba = ("#556270", "#4ECDC4", "#C7F464") ax = _check_plot_works( @@ -280,7 +283,9 @@ def test_radviz(self, iris): from pandas.plotting import radviz df = iris - _check_plot_works(radviz, frame=df, class_column="Name") + # Ensure no UserWarning when making plot + with tm.assert_produces_warning(None): + _check_plot_works(radviz, frame=df, class_column="Name") rgba = ("#556270", "#4ECDC4", "#C7F464") ax = _check_plot_works(radviz, frame=df, class_column="Name", color=rgba)