Skip to content

add bins argument to Histogram function #6850

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
Apr 23, 2014
Merged

add bins argument to Histogram function #6850

merged 1 commit into from
Apr 23, 2014

Conversation

zachcp
Copy link

@zachcp zachcp commented Apr 9, 2014

The primary argument used when plotting histograms is bins. This argument is not in the pandas documentation so you do not see it when auto-tabbing for documentation. I have added bins=10 as an argument to the dataframe and series histogram function while also adding a line of documentation. 10 is the matplotlib default bin value so this is only making bins visible, not adding or changing any plotting functionality.

@jreback
Copy link
Contributor

jreback commented Apr 9, 2014

can you move the argument to the end of the arg list pls.

@TomAugspurger
Copy link
Contributor

I'll look closer at this later, but the usual convention for our plotting functions is that any keyword arguments used in matplotlib's plot or hist or bar, etc. are passed in **kwargs.

Also you may want to use df.plot(kind='hist').

@zachcp
Copy link
Author

zachcp commented Apr 9, 2014

@jreback updated argument list
@TomAugspurger I think this is import documentation for histograms. You can use df.plot(kind="hist") but I typically use series.hist(bins=20). For historical reasons or otherwise dataframes and series can call hist directly so having histogram-specific information there makes sense to me. I can certainly see why you wouldn't want bins in df.plot().

@TomAugspurger
Copy link
Contributor

I misspoke earlier. hist isn't even a supported kind for df.plot()

@jreback
Copy link
Contributor

jreback commented Apr 22, 2014

@TomAugspurger what should we do with this?

@zachcp
Copy link
Author

zachcp commented Apr 22, 2014

I'm happy whatever you decide to do. I just rebased against upstream/master in case its a go.

@TomAugspurger
Copy link
Contributor

The downside is that this will be inconsistent with all our other plotting functions, where the arguments that go directly to the maptlotlib function are passed in the **kwargs section. But, it's good for discoverability, so let's merge.

@zachcp could you move the bins down in the docstring to match the order in the function signature?

Looks like you had a test fail too.

add bins to histrogram
@zachcp
Copy link
Author

zachcp commented Apr 22, 2014

made a couple minor fixes to padd test (need to pass bins as arg) and added two small tests.

TomAugspurger pushed a commit that referenced this pull request Apr 23, 2014
DOC: add bins argument to Histogram function
@TomAugspurger TomAugspurger merged commit a4a819f into pandas-dev:master Apr 23, 2014
@TomAugspurger
Copy link
Contributor

OK thanks.

Don't need a release notes entry since this is really just a doc change. There isn't any change to the API

@TomAugspurger
Copy link
Contributor

Oops, looks like we missed a call to hist in hist_frame. Not surprising given how spread out the code is. I've got a PR coming

@zachcp zachcp deleted the histograms branch April 23, 2014 03:23
@TomAugspurger
Copy link
Contributor

merged #6935

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

Successfully merging this pull request may close these issues.

3 participants