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

Already on GitHub? Sign in to your account

Add sort_columns parameter to plot to allow unsorted plots #918

Merged
merged 1 commit into from Mar 15, 2012
Jump to file or symbol
Failed to load files and symbols.
+9 −2
Split
View
@@ -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.
@@ -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
@@ -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)