Skip to main content
 首页 » 编程设计

Python:如何更改 matplotlib 图中轴的粒度

2024年10月25日8lori

我想知道如何在 matplotlib python pandas 中更改线图中的 bin 数量? 就像我的 x 轴范围是 [0,1000] 并且我希望它被决定为 200 个刻度。有人可以帮忙吗?

请您参考如下方法:

使用set_ticks函数

from matplotlib import pyplot as plt 
 
fig, ax = plt.subplots() 
ax.set_xticks([0,200,400,800,1000])