From 1796fad81f910b59a6f1be39cd866d79f80b7784 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Fri, 6 Nov 2015 11:45:14 +0100 Subject: [PATCH] BUG: fix incorrect xticklabels when specifying xticks (GH11529) --- doc/source/whatsnew/v0.17.1.txt | 2 +- pandas/tests/test_graphics.py | 7 +++++++ pandas/tools/plotting.py | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v0.17.1.txt b/doc/source/whatsnew/v0.17.1.txt index 0d0f4c66c1fec..e8078accba176 100755 --- a/doc/source/whatsnew/v0.17.1.txt +++ b/doc/source/whatsnew/v0.17.1.txt @@ -101,7 +101,7 @@ Bug Fixes - +- Fix regression in setting of ``xticks`` in ``plot`` (:issue:`11529`). diff --git a/pandas/tests/test_graphics.py b/pandas/tests/test_graphics.py index b85f4628ae013..7e6aaa8213667 100644 --- a/pandas/tests/test_graphics.py +++ b/pandas/tests/test_graphics.py @@ -1237,6 +1237,13 @@ def test_time_series_plot_color_with_empty_kwargs(self): ax = s.plot() self._check_colors(ax.get_lines(), linecolors=def_colors[:ncolors]) + def test_xticklabels(self): + # GH11529 + s = Series(np.arange(10), index=['P%02d' % i for i in range(10)]) + ax = s.plot(xticks=[0,3,5,9]) + exp = ['P%02d' % i for i in [0,3,5,9]] + self._check_text_labels(ax.get_xticklabels(), exp) + @tm.mplskip class TestDataFramePlots(TestPlotBase): diff --git a/pandas/tools/plotting.py b/pandas/tools/plotting.py index 98d6f5e8eb797..c6a29c7d5bb9d 100644 --- a/pandas/tools/plotting.py +++ b/pandas/tools/plotting.py @@ -985,11 +985,11 @@ def generate(self): self._make_plot() self._add_table() self._make_legend() + self._adorn_subplots() for ax in self.axes: self._post_plot_logic_common(ax, self.data) self._post_plot_logic(ax, self.data) - self._adorn_subplots() def _args_adjust(self): pass