如何获得[a,b,c]的x轴值显示?
import pandas as pd import matplotlib.pyplot as plt s = pd.Series([1, 2, 10], index=['a', 'b', 'c']) s.plot() plt.show()
您可以使用来显示xtick标签plt.xticks:
plt.xticks
import pandas as pd import matplotlib.pyplot as plt s = pd.Series([1, 2, 10], index=['a', 'b', 'c']) s.plot() plt.xticks(np.arange(len(s.index)), s.index) plt.show()
输出: