以下这个案例,基本上是我们平时注释用的最多的,其基本思想就是,找到你想要注释的那个位置,进行注释,有的时候可以觉得用定死的方式来做,显示出的效果也会很好。
平时可以多看看官网教程:text
#!/usr/bin/python
#coding: utf-8
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(-10, 11, 1) #形成一个数组,第三个参数表示步长,#start,end,step
y = x ** 2
plt.plot(x, y)
# 第一个参数是x轴坐标
# 第二个参数是y轴坐标
# 第三个参数是要显式的内容
# alpha 设置字体的透明度
# family 设置字体
# size 设置字体的大小
# style 设置字体的风格
# wight 字体的粗细
# bbox 给字体添加框,alpha 设置框体的透明度, facecolor 设置框体的颜色
plt.text(-3, 20, "function: y = x * x", size = 15, alpha = 0.2)
plt.text(-3, 40, "function: y = x * x", size = 15,\
family = "fantasy", color = "r", style = "italic", weight = "light",\
bbox = dict(facecolor = "r", alpha = 0.2))
plt.show()
感谢网上的一位博主,我们都共同努力,让有用的信息给多一点,对他人帮助也更大一点。以下是他的链接:
https://blog.youkuaiyun.com/you_are_my_dream/article/details/53455256