Compound_ID,Averages
0 M0001,0.75
1 M0002,0.87
2 M003,0.45
不是在x轴上显示'Compound_ID'而是显示索引。当我明确地尝试绘制时,它会引发错误。
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
df = pd.read_csv('teste.csv')
plt.plot(df['Averages'], df['Compound_ID'])
plt.show()
AttributeError: 'Series' object has no attribute 'find'
这可能很容易解决,但有人可以查看我的代码吗?
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
df = pd.read_csv('teste.csv')
plt.plot(df['Averages'])
plt.show()
答案 0 :(得分:2)
你可以这样做:
plt.plot(df['Averages'])
plt.xticks(range(len(df['Compound_ID'])) , df['Compound_ID'])
这样你就可以分别绘制xticks。第一个元素是数字索引,第二个名称。