您的位置:首页 > 其它

绘图-图形(柱状图)中添加纯文本注释(text)

2018-04-03 15:42 417 查看
转载至:https://blog.csdn.net/you_are_my_dream/article/details/53455256

在图形中,通过text添加纯文本的注释

text所有相关的参数:官网链接

[python] view plain copy #!/usr/bin/python  
#coding: utf-8  
  
import numpy as np  
import matplotlib.pyplot as plt  
  
x = np.arange(-10, 11, 1)  
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()  

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐