From 7c2a0955e4f8bdd7564a1336a86e42f384680c36 Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Fri, 28 Aug 2020 00:38:40 -0500 Subject: [PATCH 1/3] CLN: resolve UserWarning #35945 --- pandas/plotting/_matplotlib/core.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandas/plotting/_matplotlib/core.py b/pandas/plotting/_matplotlib/core.py index b490e07e43753..ab82710507487 100644 --- a/pandas/plotting/_matplotlib/core.py +++ b/pandas/plotting/_matplotlib/core.py @@ -1219,8 +1219,6 @@ def _update_stacker(cls, ax, stacking_id, values): ax._stacker_neg_prior[stacking_id] += values def _post_plot_logic(self, ax, data): - from matplotlib.ticker import FixedLocator - def get_label(i): if is_float(i) and i.is_integer(): i = int(i) @@ -1232,8 +1230,8 @@ def get_label(i): if self._need_to_set_index: xticks = ax.get_xticks() xticklabels = [get_label(x) for x in xticks] + ax.set_xticks(xticks) ax.set_xticklabels(xticklabels) - ax.xaxis.set_major_locator(FixedLocator(xticks)) condition = ( not self._use_dynamic_x() From 23852895b40456cb1851396598271a07b6f2ddb4 Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Fri, 28 Aug 2020 10:57:07 -0500 Subject: [PATCH 2/3] resolve UserWarning #35945 --- pandas/plotting/_matplotlib/core.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/plotting/_matplotlib/core.py b/pandas/plotting/_matplotlib/core.py index ab82710507487..646ed09331278 100644 --- a/pandas/plotting/_matplotlib/core.py +++ b/pandas/plotting/_matplotlib/core.py @@ -1219,6 +1219,8 @@ def _update_stacker(cls, ax, stacking_id, values): ax._stacker_neg_prior[stacking_id] += values def _post_plot_logic(self, ax, data): + from matplotlib.ticker import FixedLocator + def get_label(i): if is_float(i) and i.is_integer(): i = int(i) @@ -1230,7 +1232,7 @@ def get_label(i): if self._need_to_set_index: xticks = ax.get_xticks() xticklabels = [get_label(x) for x in xticks] - ax.set_xticks(xticks) + ax.xaxis.set_major_locator(FixedLocator(xticks)) ax.set_xticklabels(xticklabels) condition = ( From d46025b897b70d97ff908e165e9af11c179778f5 Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Thu, 3 Sep 2020 00:32:39 -0500 Subject: [PATCH 3/3] CLN: add warning check #35945 --- pandas/tests/plotting/test_frame.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index ee43e5d7072fe..9ab697cb57690 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -2796,10 +2796,12 @@ def test_table(self): _check_plot_works(df.plot, table=True) _check_plot_works(df.plot, table=df) - ax = df.plot() - assert len(ax.tables) == 0 - plotting.table(ax, df.T) - assert len(ax.tables) == 1 + # GH 35945 UserWarning + with tm.assert_produces_warning(None): + ax = df.plot() + assert len(ax.tables) == 0 + plotting.table(ax, df.T) + assert len(ax.tables) == 1 def test_errorbar_scatter(self): df = DataFrame(np.random.randn(5, 2), index=range(5), columns=["x", "y"])