Skip to content

Add sort_columns parameter to plot to allow unsorted plots #918

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 1 commit into from
Mar 15, 2012
Merged
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
11 changes: 9 additions & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3845,7 +3845,7 @@ def boxplot(self, column=None, by=None, ax=None, fontsize=None,

def plot(self, subplots=False, sharex=True, sharey=False, use_index=True,
figsize=None, grid=True, legend=True, rot=30, ax=None,
kind='line', **kwds):
kind='line', sort_columns=True, **kwds):
"""
Make line plot of DataFrame's series with the index on the x-axis using
matplotlib / pylab.
Expand All @@ -3861,6 +3861,8 @@ def plot(self, subplots=False, sharex=True, sharey=False, use_index=True,
use_index : boolean, default True
Use index as ticks for x axis
kind : {'line', 'bar'}
sort_columns: boolean, default True
Sort column names to determine plot ordering
kwds : keywords
Options to pass to Axis.plot

Expand Down Expand Up @@ -3903,7 +3905,12 @@ def plot(self, subplots=False, sharex=True, sharey=False, use_index=True,
need_to_set_xticklabels = False
x = range(len(self))

for i, col in enumerate(_try_sort(self.columns)):
if sort_columns:
columns = _try_sort(self.columns)
else:
columns = self.columns

for i, col in enumerate(columns):
empty = self[col].count() == 0
y = self[col].values if not empty else np.zeros(x.shape)

Expand Down