简体   繁体   English

如何在使用pandas.DataFrame.plot()构造时间序列图时添加y轴标签

[英]How to add a y-axis label while using pandas.DataFrame.plot() for constructing a time series plot

This is my code. 这是我的代码。 I looked at the documentation but didn't find the answer. 我查看了文档,但没有找到答案。

 import pandas as pd
 import matplotlib.pyplot as plt
 from datetime import datetime
 avs = pd.read_csv('daily_2004_2014.csv')
 avs = avs.set_index(pd.DatetimeIndex(avs['Date']))
 fig = plt.figure()
 avs.plot()
 plt.show()

Here is the generated image 这是生成的图像

The plot function returns axes. 绘图功能返回轴。

axes = avs.plot()

Then you can edit the axes in any way you want. 然后,您可以按任意方式编辑轴。 In your case 就你而言

axes.set_ylabel('Desired Label')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM