‘2022-03-27’, ‘2022-03-28’, ‘2022-03-29’, ‘2022-03-30’,
‘2022-03-31’, ‘2022-04-01’, ‘2022-04-04’, ‘2022-04-05’,
‘2022-04-06’], rotation=45)
plt.title(‘某股票收盘价时序图’)
plt.xlabel(‘日期’)
plt.ylabel(‘价格’)
plt.grid(True)
plt.legend()
标出每天的收盘价
for a, b in zip(x, y):
plt.text(a, b+0.01, ‘%.1f’%b, ha=‘center’, va=‘bottom’, fontsize=9)
plt.show()
=============================================================================================
在上例代码的基础之上,添加注释。注释即对图像中某一位置的解释,可以用箭头来指向。
添加注释使用的是plt.annotate()方法
其语法中的常用参数如下
plt.annotate(str,xy,xytext,xycoords,arrowcoords)
其中str即注释要使用的字符串&#