import matplotlib.pyplot as plt
import calendar
#change the numeric representation to texts (201501 -> Jan,2015)
df['month_name'] = [','.join([calendar.month_name[int(date[-1:-3]),date[-3:]] for date in df['month']
#change the type of df['month'] to int so plt can read it
df['month'].apply(int)
x = df['month']
y = df['total_gmv']
plt.bar(x, y, align = 'center')
#i'm not sure if you have to change the Series to a list; do whatever works
plt.xticks =(x, df['month_name'])
plt.show()
结果:
^{pr2}$以前的答复有一些线索,但没有显示详尽的答案。 您必须设置自定义的xtick标签并按如下方式旋转:
您应该使用
matplotlib.pyplot
和calendar
模块。在相关问题 更多 >
编程相关推荐