gpt4 book ai didi

python - Pandas 情节改变 y 轴

转载 作者:太空宇宙 更新时间:2023-11-04 09:56:51 25 4
gpt4 key购买 nike

我有一个看起来像这样的 DataFrame

enter image description here

我想绘制它:

df2[['width', 'height', 'depth']].head(20).plot.bar(figsize=(8, 8), fontsize=16)

enter image description here

效果很好,但我需要增加 Y 轴的点数。我想添加 2400、1900 等数字。我该怎么做?为什么 Y 轴上只有 6 个点?

最佳答案

好的,所以您只需要传入 yticks 参数即可。 yticks 不是 bar 的直接参数,而是传递给 plot

df2[['width', 'height', 'depth']].head(20).plot.bar(figsize=(8, 8), fontsize=16, yticks = range(0,2600,200))
plt.show()

结果:

enter image description here

如果你想对 x 轴做同样的事情,你也可以使用 xticks

关于python - Pandas 情节改变 y 轴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45478318/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com