标签: python pandas matplotlib
如何显示[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()
答案 0 :(得分:9)
您可以使用plt.xticks显示xtick标签:
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()
输出: