Skip to content

Added ind and bw_method kwargs to KdePlot #4316

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

Merged
merged 1 commit into from
Aug 26, 2013

Conversation

khgitting
Copy link

Adds ability to set the bandwidth used for the kde and the indices at which it is evaluated. The first is passed to the bw_method kwarg for scipy.stats.gaussian_kde (for scipy >= 0.11.0); the second is passed to gkde.evaluate. For the case when scipy < 0.11.0 but bw_method is specified, bw_method is ignored (not passed to scipy.stats.gaussian_kde), but a warning is issued to alert the user.

#4298

@jreback
Copy link
Contributor

jreback commented Jul 22, 2013

looking good....pls add a mention in v0.13.0.txt and doc/source.release.rst (in the 0.13 section)

@jreback
Copy link
Contributor

jreback commented Jul 22, 2013

great...looks mergable (as soon as we start the 0.13 ones)...@cpcloud?

_check_plot_works(self.ts.plot, kind='kde', bw_method=.5, ind=linspace(-100,100,20))
_check_plot_works(self.ts.plot, kind='density', bw_method=.5, ind=linspace(-100,100,20))
ax = self.ts.plot(kind='kde', logy=True, bw_method=.5, ind=linspace(-100,100,20))
self.assert_(ax.get_yscale() == 'log')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can u make this self.assertEqual(ax.get_yscale(), 'log') so that if it ever fails we can see what the value of the left hand side is? thanks.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can totally do that.

I modeled this test on the test_kde test:

    @slow
    def test_kde(self):
        _skip_if_no_scipy()
        _check_plot_works(self.ts.plot, kind='kde')
        _check_plot_works(self.ts.plot, kind='density')
        ax = self.ts.plot(kind='kde', logy=True)
        self.assert_(ax.get_yscale() == 'log')

    @slow
    def test_kde_kwargs(self):
        _skip_if_no_scipy()
        from numpy import linspace
        _check_plot_works(self.ts.plot, kind='kde', bw_method=.5, ind=linspace(-100,100,20))
        _check_plot_works(self.ts.plot, kind='density', bw_method=.5, ind=linspace(-100,100,20))
        ax = self.ts.plot(kind='kde', logy=True, bw_method=.5, ind=linspace(-100,100,20))
        self.assert_(ax.get_yscale() == 'log')

Will change in both to be consistent, and to add the usefulness you describe to the already existing test as well.

@jreback
Copy link
Contributor

jreback commented Aug 23, 2013

@khgitting this looks good, can you rebase on master, then good to go?

@khgitting
Copy link
Author

@jreback done.

@jreback
Copy link
Contributor

jreback commented Aug 26, 2013

@khgitting can you squash to 1 commit?

(like a rebase, but use 's' on the other commits)

@khgitting
Copy link
Author

@jreback Rebased, squashing, on top of a fresh master from fetching upstream.

jreback added a commit that referenced this pull request Aug 26, 2013
Added ind and bw_method kwargs to KdePlot
@jreback jreback merged commit 48658fb into pandas-dev:master Aug 26, 2013
@jreback
Copy link
Contributor

jreback commented Aug 26, 2013

@khgitting thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants