Skip to content

Add layout support in plot_frame similar to the hist_frame layout #6667

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

Closed
wants to merge 1 commit into from
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