From 7ee090ec31d4f1d4587bc6ae679eca453be24f29 Mon Sep 17 00:00:00 2001 From: TomAugspurger Date: Wed, 17 Sep 2014 15:37:31 -0500 Subject: [PATCH 1/2] VIS: default LinePlot rotation of 0 --- pandas/tests/test_graphics.py | 8 ++++++-- pandas/tools/plotting.py | 10 +++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/pandas/tests/test_graphics.py b/pandas/tests/test_graphics.py index 1e8cf4d700f39..92bd0c7c0893d 100644 --- a/pandas/tests/test_graphics.py +++ b/pandas/tests/test_graphics.py @@ -573,6 +573,10 @@ def test_bar_ignore_index(self): def test_rotation(self): df = DataFrame(randn(5, 5)) + # Default rot 0 + axes = df.plot() + self._check_ticks_props(axes, xrot=0) + axes = df.plot(rot=30) self._check_ticks_props(axes, xrot=30) @@ -974,7 +978,7 @@ def test_plot(self): self._check_visible(ax.xaxis) self._check_visible(ax.get_xticklabels()) self._check_visible([ax.xaxis.get_label()]) - self._check_ticks_props(ax, xrot=30) + self._check_ticks_props(ax, xrot=0) _check_plot_works(df.plot, title='blah') @@ -1178,7 +1182,7 @@ def test_subplots_timeseries(self): self._check_visible(axes[-1].get_xticklabels(minor=True)) self._check_visible(axes[-1].xaxis.get_label()) self._check_visible(axes[-1].get_yticklabels()) - self._check_ticks_props(axes, xrot=30) + self._check_ticks_props(axes, xrot=0) axes = df.plot(kind=kind, subplots=True, sharex=False, rot=45, fontsize=7) for ax in axes: diff --git a/pandas/tools/plotting.py b/pandas/tools/plotting.py index f8d7a16e686b7..cfba295d2816e 100644 --- a/pandas/tools/plotting.py +++ b/pandas/tools/plotting.py @@ -799,7 +799,11 @@ def __init__(self, data, kind=None, by=None, subplots=False, sharex=True, if rot is not None: self.rot = rot + # need to know for format_date_labels since it's rotated to 30 by + # default + self._rot_set = True else: + self._rot_set = False if isinstance(self._default_rot, dict): self.rot = self._default_rot[self.kind] else: @@ -1498,7 +1502,7 @@ def _post_plot_logic(self): class LinePlot(MPLPlot): - _default_rot = 30 + _default_rot = 0 orientation = 'vertical' def __init__(self, data, **kwargs): @@ -1679,6 +1683,10 @@ def _post_plot_logic(self): for ax in self.axes: if condition: + # irregular TS rotated 30 deg. by default + # probably a better place to check / set this. + if not self._rot_set: + self.rot = 30 format_date_labels(ax, rot=self.rot) if index_name is not None: From 92cc5491cfe058e66b81430aa9c15d8ba88aaa49 Mon Sep 17 00:00:00 2001 From: TomAugspurger Date: Thu, 18 Sep 2014 13:41:32 -0500 Subject: [PATCH 2/2] DOC: need blankline for example --- doc/source/visualization.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/visualization.rst b/doc/source/visualization.rst index 32892a431cd29..e1c64e641e1e7 100644 --- a/doc/source/visualization.rst +++ b/doc/source/visualization.rst @@ -1118,6 +1118,7 @@ or columns needed, given the other. The above example is identical to using .. ipython:: python + df.plot(subplots=True, layout=(-1, 3), figsize=(6, 6)); The required number of rows (2) is inferred from the number of series to plot