繁体   English   中英

用图中的数字替换列字符串

[英]Replacing column strings with numbers in a plot

有没有办法将列号指定为在 x 轴上显示的索引? 考虑以下数据框

      Metric Value Metric Value Metric Value Metric Value
0             3            3            7            7
1             1            1            1            1
2             0            0            0            0

下面的代码绘制了 row[0],但是,如您所见,“度量值”写在 x 点上。 我希望看到 1、2、3、4。

    row = df.iloc[0]
    row.astype(int).plot()
    plt.show()
    

在此处输入图片说明

尝试这个:

df.columns = range(1, len(df.columns)+1)
row = df.iloc[0]
row.astype(int).plot()
plt.show()

暂无
暂无

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

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