Skip to content

VIS: default LinePlot rotation of 0 #8301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/visualization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions pandas/tests/test_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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')

Expand Down Expand Up @@ -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:
Expand Down
10 changes: 9 additions & 1 deletion pandas/tools/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down