Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

obtain the max y-value of a histogram

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)
like image 209
zach Avatar asked Mar 21 '13 21:03

zach


People also ask

What is the maximum in a histogram?

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.

What is Y value in histogram?

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.

How do you find the max of a histogram in Matlab?

If you have the data that created the histogram then it's simply min()/max() of that data.


1 Answers

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.

like image 149
tiago Avatar answered Sep 22 '22 23:09

tiago