Skip to content
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

Improving plt.hist documentation #3084

Merged

Conversation

GregoryAshton
Copy link
Contributor

Adds a description of the return value of plot.hist(). Suggested by tcaswell in this SO post. I have tried my best to stick to the numpy doc format but admit I was confused as to if this should go in the return statement or the extended description at the top of the docstring.

@@ -5388,6 +5388,11 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
-------
tuple : ``(n, bins, patches)`` or \
Copy link
Member

Choose a reason for hiding this comment

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

You should remove these lines.

@pelson
Copy link
Member

pelson commented May 29, 2014

👍 - I would merge this. @tacaswell?

@@ -5386,8 +5386,13 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,

Returns
-------
tuple : ``(n, bins, patches)`` or \
``([n0, n1, ...], bins, [patches0, patches1,...])``
n : array
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be 'array or list of arrays', the latter is if you call hist with `hist([data1, data2, ...])

@GregoryAshton
Copy link
Contributor Author

I had not though of that, as far as I am aware bins should always be a single array of the bin edges.

@tacaswell
Copy link
Member

You should also add a note about how the list elements map to the input. While you are working on this documentation could you also update the input docs to state that you can pass in hist([data1, data2...])? The prose says you can, but the Parameters section does not.

@GregoryAshton
Copy link
Contributor Author

Okay @tacaswell. For the x parameter, it currently has array_like, shape (n, ) . But if hist([data1, data2...]) then the shape will be either:

  • (n, m) where n is the number of data sets and m the length of data sets if they are all the same
  • (n,) where n is the number of data sets if the data sets are of different lengths.

Is it okay to leave out the shape of the return from the parameters section or is it required? I feel like it will just be more confusing if it is left in.

@tacaswell
Copy link
Member

This is the cost of writing 'simple' functions that 'just work'.

I would say something like '(n,) array or sequence of (n,) arrays'

@tacaswell tacaswell added this to the v1.4.0 milestone Jun 29, 2014
@tacaswell tacaswell merged commit eea040e into matplotlib:master Jun 29, 2014
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.

4 participants