본문 바로가기

Python

Histogram function

반응형
def _Histogram(data, start_range, end_range, delta, x1, x2, y1, y2):

# the histogram of the data
bins = []
while (start_range < end_range):
bins.append(start_range)
start_range = start_range + delta

values, bins, patches = plt.hist(data, bins, normed=False)

plt.xlabel('Input Data Value')
plt.ylabel('Occurrence')
plt.grid(True)
plt.axis([x1, x2, y1, y2])
plt.show()
def _Histogram(data, min_val, max_val, delta):

mid_val = 0.5*(min_val + max_val)
if (abs(max_val - mid_val) > abs(min_val - mid_val)):
start_range = mid_val - abs(max_val - mid_val)
end_range = mid_val + abs(max_val - mid_val)
else:
start_range = mid_val - abs(min_val - mid_val)
end_range = mid_val + abs(min_val - mid_val)

# the histogram of the data
bins = []
start_range_tmp = start_range
while (start_range_tmp < end_range):
bins.append(start_range_tmp)
start_range_tmp = start_range_tmp + delta

values, bins, patches = plt.hist(data, bins, normed=False)

plt.xlabel('Input Data Value')
plt.ylabel('Occurrence')
plt.grid(True)
plt.axis([start_range, end_range, 0, np.max(values)])
plt.show()

return 0


'Python' 카테고리의 다른 글

Random int generation in range  (0) 2018.10.30
How to fit a curve using scipy.optimize.curve  (0) 2018.10.29
Copy files in a directory to another directory  (0) 2017.12.01
Get file list in a directory  (0) 2017.11.30
Perspective transform  (0) 2017.11.21