Skip to content

Commit 78fec85

Browse files
author
Chang She
committed
ENH: KdePlot with DataFrame #1342. TST: frame kde and kde with logy #1341
1 parent 7fffdb5 commit 78fec85

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

pandas/tests/test_graphics.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ def test_hist(self):
5656
_check_plot_works(self.ts.hist)
5757
_check_plot_works(self.ts.hist, grid=False)
5858

59+
@slow
60+
def test_kde(self):
61+
_check_plot_works(self.ts.plot, kind='kde')
62+
ax = self.ts.plot(kind='kde', logy=True)
63+
self.assert_(ax.get_yscale() == 'log')
5964

6065
class TestDataFramePlots(unittest.TestCase):
6166

@@ -162,6 +167,15 @@ def test_boxplot(self):
162167

163168
_check_plot_works(lambda x: plotting.boxplot(x), df['one'])
164169

170+
@slow
171+
def test_kde(self):
172+
df = DataFrame(np.random.randn(100, 4))
173+
_check_plot_works(df.plot, kind='kde')
174+
_check_plot_works(df.plot, kind='kde', subplots=True)
175+
axes = df.plot(kind='kde', logy=True, subplots=True)
176+
for ax in axes:
177+
self.assert_(ax.get_yscale() == 'log')
178+
165179
@slow
166180
def test_hist(self):
167181
df = DataFrame(np.random.randn(100, 4))

pandas/tools/plotting.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,8 @@ def plot_frame(frame=None, subplots=False, sharex=True, sharey=False,
678678
klass = LinePlot
679679
elif kind in ('bar', 'barh'):
680680
klass = BarPlot
681+
elif kind == 'kde':
682+
klass = KdePlot
681683
else:
682684
raise ValueError('Invalid chart type given %s' % kind)
683685

0 commit comments

Comments
 (0)