Skip to content
Closed
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
16 changes: 14 additions & 2 deletions pandas/tools/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ def __init__(self, data, kind=None, by=None, subplots=False, sharex=True,
ax=None, fig=None, title=None, xlim=None, ylim=None,
xticks=None, yticks=None,
sort_columns=False, fontsize=None,
secondary_y=False, colormap=None, **kwds):
secondary_y=False, colormap=None,layout=None,**kwds):

self.data = data
self.by = by
Expand All @@ -803,6 +803,7 @@ def __init__(self, data, kind=None, by=None, subplots=False, sharex=True,
self.sort_columns = sort_columns

self.subplots = subplots
self.layout = layout
self.sharex = sharex
self.sharey = sharey
self.figsize = figsize
Expand Down Expand Up @@ -985,7 +986,18 @@ def _setup_subplots(self):
self.axes = axes

def _get_layout(self):
return (len(self.data.columns), 1)
n = len(self.data.columns)
if self.layout is not None:
if not isinstance(self.layout, (tuple, list)) or len(self.layout) != 2:
raise ValueError('Layout must be a tuple of (rows, columns)')

rows, cols = self.layout
if rows * cols < n:
raise ValueError('Layout of %sx%s is incompatible with %s columns' % (rows, cols, n))
return self.layout
else :
return (n, 1)


def _compute_plot_data(self):
numeric_data = self.data.convert_objects()._get_numeric_data()
Expand Down