-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Create kwarg to normalize histogram such that sum of bin values equals 1 #1567
Comments
how about having normed accept multiple types |
@piti118 That's a good call. Might I suggest |
Usually, I am against such ideas where a parameter can accept multiple types, but this might be a case where the use-case is compelling enough to over-ride such concerns. In this situation, the requested feature is not orthogonal to the existing features, and so adding a new kwarg would only complicate things. I would suggest keeping it as simple as possible, though, and accept only booleans and (positive) numbers, to start. This approach makes sense because True == 1. Strings and callables I would avoid for now until a really compelling use-case is put forth. |
@WeatherGod I humbly disagree with your suggestion to limit the kwarg values to booleans and positive integers. My concern is that it makes for very cryptic function calls because it's not immediately clear what the integers represent. The original issue is that matplotlib normalizes the area under the curve to 1 instead of the height of the bars. In this case, it's not the numerical value that's of primary importance, but what that value represents. If we were to make it so that Basically, I want to avoid the situation where I constantly have to refer to the documentation to remember which value to pass. A call such as |
@WeatherGod I'm just toying the idea and alternative around. Your expert comment is more than welcome. But in this case there are two types of normalization we need to distinguish.
If we only allow normed=1., I'm not sure which one it will be using. I hate adding another kwarg too but we might need one in this case. Lets call it normed keyword in numpy histogram is being deprecated anyway. |
On Thu, Dec 13, 2012 at 8:22 PM, Piti Ongmongkolkul <
|
I'd be willing to take a stab at fixing this, but I've never contributed anything significant before. If someone feels like doing it instead, the community might be better off! In the meantime, is this the place to ask for clarification regarding the code in |
Contributing code is easy and fun. I have contributed to matplotlib couple times. I found the community to be super friendly. Just make a pull request/issue and one of repo collab will help you. |
@piti118 Alright, then! I'll take a crack at it sometime this week. If I get stuck, I'll be sure to let someone know. |
matplotlib-users list for help with using it, matplotlib-devel list for proposing changes. sign up here (note, the archives are broken on there, you can find the archives here) |
It is feedback like this that makes me happy to contribute to this open source project. Thank you. |
How's progress on this coming? I'm doing some work on the hist function anyway, so I could probably implement this if no one has started working on it yet. What would make sense to me would be to let |
@nic I haven't had a chance to get started -- have at it! On Sat, Jan 26, 2013 at 4:27 PM, Nic Eggert notifications@github.comwrote:
Louis Thibault |
@neggert et al, think there's any value in a |
At some point does it make sense to be able to pass The function would take a single argument of a numpy array (the raw bin counts), and returns an array of the exact same shape scaled how ever the user wants. Does it make sense to try and leverage the |
Hmm, it does look like what |
I never claimed it would be simple ;) , but there was recently discussion of developing a way to make |
Ah, fair enough. On Sat, Mar 16, 2013 at 3:43 PM, Thomas A Caswell
|
I just can't commit to this before next month. Stretched pretty thin right now :/-- On Thu, Jan 16, 2014 at 2:57 PM, Thomas A Caswell
|
To be honest, I still don't really see the appeal of this feature, and the Plus, I'm already behind on the PRs I have open. |
Fair enough. I am going to close this. If anyone is interested in implementing this feel free to re-open. |
This StackOverflow question sums up the problem pretty well. The answer is straightforward but convoluted. This kind of functionality is widely used and requested, so it would be of great benefit for the
hist
function to handle it automatically.Basically, setting the
normed
kwarg to a logically true value normalizes the histogram such that the integral is equal to 1. I suggest creating a new kwarg, named something likenormedheight
(or perhapsnormedh
), which implements the solution proposed in the StackOverflow post.Here is the code, for convenience:
The text was updated successfully, but these errors were encountered: