Pandas/matplotlib 线图不显示 x 轴文本标签

问题


将 DataFrame 中的数据绘制到线图中不包括 x 轴上的“日期”。


north_result = list(data.aggregate(pipeline))


dates =['Jun','Jul','Aug','Sep','Oct','Nov','Dec','Jan','Feb','Mar','Apr','May']

north_result_df = pd.DataFrame(north_result, index=dates)

north_result_df.index.name = 'Months'

north_result_df.plot.line()

http://img3.mukewang.com/61a5df01000112a404670307.jpg

问题


将 DataFrame 中的数据绘制到线图中不包括 x 轴上的“日期”。


north_result = list(data.aggregate(pipeline))


dates =['Jun','Jul','Aug','Sep','Oct','Nov','Dec','Jan','Feb','Mar','Apr','May']

north_result_df = pd.DataFrame(north_result, index=dates)

north_result_df.index.name = 'Months'

north_result_df.plot.line()


一只萌萌小番薯
浏览 153回答 1
1回答

不负相思意

你可以使用 pyplotimport matplotlib.pyplot as pltnorth_result =[5,6,7,2,8,5,4,8,9,4,1,5]dates =['Jun','Jul','Aug','Sep','Oct','Nov','Dec','Jan','Feb','Mar','Apr','May']north_result_df = pd.DataFrame(north_result, index=dates)north_result_df.index.name = 'Months'plt.plot(north_result_df)plt.show()结果将是这样的:
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python