首页 > 解决方案 > 使用 matplotlib.figure 更改刻度间隔

问题描述

有没有办法改变 x 值的间隔?他们现在非常聚集,我不需要向所有人展示,我可能只需要展示每 20 个人中的 1 个。

图表图片

def create_window_graph(xas,yas,labname):

fig = Figure(figsize=(8, 4), dpi=80)

fig.add_subplot(111).plot(xas,yas, 'r--', label = labname) 


fig.legend()

标签: pythonmatplotlibgraphfigure

解决方案


使用 maptplotlib.pyplot 非常简单:

ax.set_xlim(xmin = , xmax = )

您可以在此处查看完整文档:

https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.axes.Axes.set_xlim.html


推荐阅读