Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


hist plot in percent #320

ddale opened this Issue · 9 comments

8 participants


Original report at SourceForge, opened Mon Apr 20 04:48:03 2009

except for normed=1 there is no way to control the y output of hist.
being able to specify an output in percent would be useful.

hist(x, percent=1)
plots y/n*100 histograms


Clarification: Implement a "percent" option on hist.
As a workaround, one could just use the normed with a custom formatter:

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker

plt.hist(np.linspace(0.1, 5.5, 1000), normed=True, bins=range(10))
formatter = mticker.FuncFormatter(lambda v, pos: str(v * 100))

I can't say I am that keen to implement another keyword on the hist function. Thoughts?


Me neither. This is more of a formatter issue than anything else. If anything, we could add an example to the gallery or even the hist api docs.


Good idea. We don't have access to the original author, but lets make the action of this issue to: "Put an example of making a percentage histogram in the mpl gallery".

I'm not sure if its best to use locators for this, or if some clever use of scales might be appropriate.


Ok -- and I think if the action is to just create a new example, we can reasonably get this in 1.2, so I'm marking it for that milestone.


Closed by #1149.

@mdboom mdboom closed this

Is there any chance of extending the API to accept the percent=1 parameter as @ddale suggested? I saw your example introduced in #1149 and I really don't like the idea of adding so much code just to have yticks as percentages - the normal, textbook way of annotating histograms.


I deffinetly agree with kermit666
it would have been great if it was as simple as adding percent=1 (especially that it is very common for histograms to be plotted in percentage)


It is unlikely that we will add this, the signature for hist is awful enough as it is. We already have a normed kwarg, how would we deal with the case where the user passes in both normed and percent?

A better route might be to add a normed_value kwarg which defaults to 1 such that the result is rescaled so that it integrates to normed_value.

I have never plotted a histogram in percent so I contest the assertions that this is the 'textbook' or even a common thing.

@neggert, comments?


This is similar to #1567. I think my thoughts are summed up towards the end of that thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.