首页 > 解决方案 > 线型图看不到 x 轴标签

问题描述

我正在测试一个非常简单的练习,只需绘制下面的代码:

t = pd.Series([1,2,5,1,8], index=['a', 's', 'l', 'f', 'd' ])
t.plot(linestyle = '-', color = 'b', sharex = True)

但我看不到字母a, s, l,fd.

有什么建议么?

标签: pythonpandas

解决方案


你可以像这样:

import pandas as pd
from matplotlib import pyplot as plt

t = pd.Series([1,2,5,1,8], index=['a', 's', 'l', 'f', 'd' ]) 
plt.plot(t.index, t.values,linestyle = '-', color = 'b')
plt.show()

图片在以下链接中

改编自这里


推荐阅读