Skip to content

Commit c91572b

Browse files
committed
TST: plot methods return axes and test per #368, PR #385
1 parent cdc1652 commit c91572b

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

pandas/core/frame.py

+5
Original file line numberDiff line numberDiff line change
@@ -3127,6 +3127,10 @@ def plot(self, subplots=False, sharex=True, sharey=False, use_index=True,
31273127
pass
31283128

31293129
plt.draw_if_interactive()
3130+
if subplots:
3131+
return axes
3132+
else:
3133+
return ax
31303134

31313135
def _bar_plot(self, axes, subplots=False, use_index=True, grid=True,
31323136
rot=30, legend=True, **kwds):
@@ -3192,6 +3196,7 @@ def hist(self, grid=True, **kwds):
31923196
ax.set_title(col)
31933197
ax.grid(grid)
31943198

3199+
return axes
31953200
#----------------------------------------------------------------------
31963201
# Deprecated stuff
31973202

pandas/core/series.py

+4
Original file line numberDiff line numberDiff line change
@@ -1684,6 +1684,8 @@ def plot(self, label=None, kind='line', use_index=True, rot=30, ax=None,
16841684

16851685
plt.draw_if_interactive()
16861686

1687+
return ax
1688+
16871689
def hist(self, ax=None, grid=True, **kwds):
16881690
"""
16891691
Draw histogram of the input series using matplotlib
@@ -1710,6 +1712,8 @@ def hist(self, ax=None, grid=True, **kwds):
17101712
ax.hist(values)
17111713
ax.grid(grid)
17121714

1715+
return ax
1716+
17131717
def to_csv(self, path):
17141718
"""
17151719
Write the Series to a CSV file

pandas/tests/test_graphics.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,14 @@ def _check_plot_works(f, *args, **kwargs):
107107
fig = plt.gcf()
108108
plt.clf()
109109
ax = fig.add_subplot(211)
110-
f(*args, **kwargs)
110+
ret = f(*args, **kwargs)
111+
assert(ret is not None) # do something more intelligent
111112

112113
ax = fig.add_subplot(212)
113114
try:
114115
kwargs['ax'] = ax
115-
f(*args, **kwargs)
116+
ret = f(*args, **kwargs)
117+
assert(ret is not None) # do something more intelligent
116118
except Exception:
117119
pass
118120
plt.savefig(PNG_PATH)

0 commit comments

Comments
 (0)