I am looking for suggestions on how to calculate the maximum y-value of a histogram.
#simple histogram. how can I obtain the maximum value of, say, x and y?
import matplotlib.pyplot as plt
hdata = randn(500)
x = plt.hist(hdata)
y = plt.hist(hdata, bins=40)
Value distribution or histogram: Shows how the values in your column are distributed. The higher the bar, the more values fall in that range. Min and max: Shows you the lowest (minimum) and highest (maximum) values in your column. Mean: Also called the average.
A histogram is a bar graph-like representation of data that buckets a range of classes into columns along the horizontal x-axis. The vertical y-axis represents the number count or percentage of occurrences in the data for each column.
If you have the data that created the histogram then it's simply min()/max() of that data.
hist
returns a tuple that contains the histogram bin locations and y values. Try this:
y, x, _ = plt.hist(hdata)
print x.max()
print y.max()
Note that len(y) = len(x) - 1
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With