我有以下生成直方图的Python代码
data_array=[1,1,4,2,10,1]
num_bins = 12
fig = plt.figure(1, figsize=[16,9])
fig.suptitle("title")
plt.xlabel('X-Axis')
plt.ylabel('Y-Axis')
sub = plt.subplot(111)
hist_array = sub.hist(data_array, bins=num_bins, color='#54c29a', orientation='horizontal', edgecolor='black', linewidth=1)
for i in range(num_bins):
if hist_array[0][i] > 0:
sub.text(hist_array[0][i], hist_array[1][i], str(int(hist_array[0][i])), horizontalalignment="right", verticalalignment="bottom")
我该怎么做?我试过了horizontalalignment='right'
,但没用
目前没有回答
相关问题 更多 >
编程相关推荐