我正试图在Pandas数据帧的matplotlib图上设置x轴的刻度(时间步长)。我的目标是使用DataFrame的第一列作为记号,但是到目前为止我还没有成功。
到目前为止,我的尝试包括:
尝试1:#See 'xticks'
data_df[header_names[1]].plot(ax=ax, title="Roehrig Shock Data", style="-o", legend=True, xticks=data_df[header_names[0]])
尝试2:ax.xaxis.set_ticks(data_df[header_names[0]])
header_names只是列标题名称的列表,数据帧如下:Compression Velocity Compression Force
1 0.000213 6.810879
2 0.025055 140.693200
3 0.050146 158.401500
4 0.075816 171.050200
5 0.101011 178.639500
6 0.126681 186.228800
7 0.150925 191.288300
8 0.176597 198.877500
9 0.202269 203.937000
10 0.227466 208.996500
11 0.252663 214.056000
以下是CSV格式的数据:Compression Velocity,Compression Force
0.0002126891606,6.810879
0.025055073079999997,14