Skip to content

Commit 9796924

Browse files
author
Chang She
committed
BUG: figsize and title for plotting xy columns #2342
1 parent 8ce2b04 commit 9796924

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

pandas/tests/test_graphics.py

+9
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ def test_plot(self):
214214

215215
@slow
216216
def test_plot_xy(self):
217+
import matplotlib.pyplot as plt
217218
# columns.inferred_type == 'string'
218219
df = tm.makeTimeDataFrame()
219220
self._check_data(df.plot(x=0, y=1),
@@ -232,9 +233,17 @@ def test_plot_xy(self):
232233
self._check_data(df.plot(x=1), df.set_index(1).plot())
233234
self._check_data(df.plot(y=1), df[1].plot())
234235

236+
# figsize and title
237+
plt.close('all')
238+
ax = df.plot(x=1, y=2, title='Test', figsize=(16, 8))
239+
240+
self.assert_(ax.title.get_text() == 'Test')
241+
self.assert_((np.round(ax.figure.get_size_inches()) == np.array((16., 8.))).all())
242+
235243
# columns.inferred_type == 'mixed'
236244
# TODO add MultiIndex test
237245

246+
238247
@slow
239248
def test_xcompat(self):
240249
import pandas as pd

pandas/tools/plotting.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ def bootstrap_plot(series, fig=None, size=50, samples=500, **kwds):
411411
return fig
412412

413413

414-
def parallel_coordinates(data, class_column, cols=None, ax=None, colors=None,
414+
def parallel_coordinates(data, class_column, cols=None, ax=None, colors=None,
415415
**kwds):
416416
"""Parallel coordinates plotting.
417417
@@ -746,6 +746,8 @@ def _setup_subplots(self):
746746
ax = self._maybe_right_yaxis(ax)
747747
else:
748748
fig = self.ax.get_figure()
749+
if self.figsize is not None:
750+
fig.set_size_inches(self.figsize)
749751
ax = self._maybe_right_yaxis(self.ax)
750752

751753
axes = [ax]
@@ -1373,10 +1375,11 @@ def plot_frame(frame=None, x=None, y=None, subplots=False, sharex=True,
13731375
if y is not None:
13741376
if com.is_integer(y) and not frame.columns.holds_integer():
13751377
y = frame.columns[y]
1376-
return plot_series(frame[y], label=y, kind=kind, use_index=True,
1378+
return plot_series(frame[y], label=y, kind=kind, use_index=use_index,
13771379
rot=rot, xticks=xticks, yticks=yticks,
13781380
xlim=xlim, ylim=ylim, ax=ax, style=style,
13791381
grid=grid, logy=logy, secondary_y=secondary_y,
1382+
title=title, figsize=figsize, fontsize=fontsize,
13801383
**kwds)
13811384

13821385
plot_obj = klass(frame, kind=kind, subplots=subplots, rot=rot,
@@ -1393,7 +1396,6 @@ def plot_frame(frame=None, x=None, y=None, subplots=False, sharex=True,
13931396
else:
13941397
return plot_obj.axes[0]
13951398

1396-
13971399
def plot_series(series, label=None, kind='line', use_index=True, rot=None,
13981400
xticks=None, yticks=None, xlim=None, ylim=None,
13991401
ax=None, style=None, grid=None, legend=False, logy=False,

0 commit comments

Comments
 (0)