【发布时间】:2022-01-18 15:30:50
【问题描述】:
我创建了一个直方图,一切正常,唯一缺少的是 y 轴的千位分隔符。我怎样才能方便地安装一个?不幸的是,其他记录在案的答案都没有奏效。
# Creating a histogram for order_hour_of_day with titles, labels for the axes and
#thousands separator (last is still missing)
hist2 = df_final['order_hour_of_day'].plot.hist(bins = 24)
plt.title('Orders per Hour of Day')
plt.xlabel('Hour of Day')
plt.ylabel('Orders')
plt.ticklabel_format(style='plain', axis='y')
谢谢!
【问题讨论】:
-
不,实际上只是因为我的技能水平让我很困惑,对不起
-
hist2.yaxis.set_major_formatter(matplotlib.ticker.StrMethodFormatter('{x:,.0f}'))或重复链接中列出的任何其他方法,但删除行plt.ticklabel_format(style='plain', axis='y')。
标签: python pandas matplotlib plot