You need to enable JavaScript to run this app. 使用Python matplotlib与seaborn绘制人口柱状图时如何将Y轴数值以百万为单位展示
优惠活动
大模型
产品
解决方案
定价
更多

使用Python matplotlib与seaborn绘制人口柱状图时如何将Y轴数值以百万为单位展示

Matplotlib与Seaborn人口柱状图Y轴百万单位展示需求

在使用Python的matplotlib、seaborn工具基于sum_of_pop数据集绘制各州人口柱状图时,希望将Y轴的人口数值直接以百万为单位的实际数值形式展示,目前的实现代码与输出效果如下:

现有实现代码

# 柱状图绘制
plt.figure(figsize=(19, 10))
sns.barplot(x="STATE_NAME", y="pop", data=sum_of_pop, ci=None)
plt.title(elevation + "_" + pop + "_" + str(year) + "_" + lecz)
plt.xticks(rotation=35, fontsize=11)
plt.yticks(fontsize=11)
plt.xlabel("State Name", fontsize=11) 
plt.ylabel("Population", fontsize=11) 
# plt.show()
plt.savefig(
    r"C:\Users\myname\Desktop\lecz_graph\bar_graph\\" 
    + elevation + "_" + pop + "_" + str(year) + "_" + lecz + ".png", 
    dpi=400
)

当前输出效果

当前输出图


内容的提问来源于stack exchange,提问作者Qias

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.11.03 16:24:07