简体   繁体   English

熊猫情节改变了y轴

[英]Pandas plot change y axis

I have DataFrame that looks like this 我有这样的DataFrame

在此输入图像描述

I want to plot it: 我想绘制它:

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

在此输入图像描述

Works great, but there I need increase amount of points of Y axis. 效果很好,但我需要增加Y轴的点数。 I want to add numbers like 2400, 1900, etc. How can I do that? 我想添加2400,1900等数字。我该怎么做? Why is there only 6 points on Y axis ? 为什么Y轴上只有6个点?

Okay so you only need to pass in the yticks argument. 好的,所以你只需要传递yticks参数。 yticks is not a direct argument for bar but it passed on to plot . yticks不是bar的直接论据,但它传递给了plot

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

Result: 结果:

在此输入图像描述

You can also use xticks if you want to do the same for the x-axis 如果要对x轴执行相同操作,也可以使用xticks

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM