Python 如何在matplotlib中更改为x记号间隔?

Python 如何在matplotlib中更改为x记号间隔?,python,matplotlib,Python,Matplotlib,如何以特定的频率对绘图进行XTICK?这是我的密码: # read data df = pd.read_csv("newData/000001.csv") df1 = df.loc[df['seqNo'] == 48] df1 = df1.sort_values(by = 'date') df1['date'] = df1['date'].astype(str) # show plot plt.plot(df1['date'], df1['close'], 'yellow', label = '

如何以特定的频率对绘图进行XTICK?这是我的密码:

# read data
df = pd.read_csv("newData/000001.csv")
df1 = df.loc[df['seqNo'] == 48]
df1 = df1.sort_values(by = 'date')
df1['date'] = df1['date'].astype(str)
# show plot
plt.plot(df1['date'], df1['close'], 'yellow', label = 'close')
plt.legend()
plt.xlabel("date")
plt.ylabel("value")
plt.title("000001")
plt.show()
图中,x轴太密集了:

图中的部分是:


xaxis的数据类型为字符串。

您可以使用默认打印:

df = pd.read_csv("newData/000001.csv")
df1 = df.loc[df['seqNo'] == 48]
df1 = df1.sort_values(by = 'date')

p = df.plot('date', 'close',  color='yellow', title="000001")
p.set_ylabel('value')
这会自动设置x记号的间距

例如:


如何每隔10或100次显示一次X点?不要使用字符串,如果要打印日期,请参阅