-
Matplotlib histogram의 바에 갯수 띄우기카테고리 없음 2022. 2. 24. 15:45
코드
import matplotlib.pyplot as plt import numpy as np h = np.random.normal(loc=9,scale=6, size=400).astype(int)+15 fig, ax = plt.subplots(figsize=(16, 10)) ax.hist(h, density=False) for rect in ax.patches: height = rect.get_height() ax.annotate(f'{int(height)}', xy=(rect.get_x()+rect.get_width()/2, height), xytext=(0, 5), textcoords='offset points', ha='center', va='bottom')
결과
출처