Skip to content

Commit 89cf72b

Browse files
author
Tom Augspurger
committed
Merge pull request #8301 from TomAugspurger/default-rot
VIS: default LinePlot rotation of 0
2 parents 25810c6 + 92cc549 commit 89cf72b

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

Diff for: doc/source/visualization.rst

+1
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,7 @@ or columns needed, given the other.
11181118
The above example is identical to using
11191119

11201120
.. ipython:: python
1121+
11211122
df.plot(subplots=True, layout=(-1, 3), figsize=(6, 6));
11221123
11231124
The required number of rows (2) is inferred from the number of series to plot

Diff for: pandas/tests/test_graphics.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,10 @@ def test_bar_ignore_index(self):
573573

574574
def test_rotation(self):
575575
df = DataFrame(randn(5, 5))
576+
# Default rot 0
577+
axes = df.plot()
578+
self._check_ticks_props(axes, xrot=0)
579+
576580
axes = df.plot(rot=30)
577581
self._check_ticks_props(axes, xrot=30)
578582

@@ -974,7 +978,7 @@ def test_plot(self):
974978
self._check_visible(ax.xaxis)
975979
self._check_visible(ax.get_xticklabels())
976980
self._check_visible([ax.xaxis.get_label()])
977-
self._check_ticks_props(ax, xrot=30)
981+
self._check_ticks_props(ax, xrot=0)
978982

979983
_check_plot_works(df.plot, title='blah')
980984

@@ -1178,7 +1182,7 @@ def test_subplots_timeseries(self):
11781182
self._check_visible(axes[-1].get_xticklabels(minor=True))
11791183
self._check_visible(axes[-1].xaxis.get_label())
11801184
self._check_visible(axes[-1].get_yticklabels())
1181-
self._check_ticks_props(axes, xrot=30)
1185+
self._check_ticks_props(axes, xrot=0)
11821186

11831187
axes = df.plot(kind=kind, subplots=True, sharex=False, rot=45, fontsize=7)
11841188
for ax in axes:

Diff for: pandas/tools/plotting.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,11 @@ def __init__(self, data, kind=None, by=None, subplots=False, sharex=True,
799799

800800
if rot is not None:
801801
self.rot = rot
802+
# need to know for format_date_labels since it's rotated to 30 by
803+
# default
804+
self._rot_set = True
802805
else:
806+
self._rot_set = False
803807
if isinstance(self._default_rot, dict):
804808
self.rot = self._default_rot[self.kind]
805809
else:
@@ -1498,7 +1502,7 @@ def _post_plot_logic(self):
14981502

14991503
class LinePlot(MPLPlot):
15001504

1501-
_default_rot = 30
1505+
_default_rot = 0
15021506
orientation = 'vertical'
15031507

15041508
def __init__(self, data, **kwargs):
@@ -1679,6 +1683,10 @@ def _post_plot_logic(self):
16791683

16801684
for ax in self.axes:
16811685
if condition:
1686+
# irregular TS rotated 30 deg. by default
1687+
# probably a better place to check / set this.
1688+
if not self._rot_set:
1689+
self.rot = 30
16821690
format_date_labels(ax, rot=self.rot)
16831691

16841692
if index_name is not None:

0 commit comments

Comments
 (0)