• python-annotation与text详细解释


    import matplotlib.pyplot as plt
    import numpy as np
    fig=plt.figure()
    ax1=fig.add_subplot(121)
    t=np.arange(0.0,5,0.01)
    s=np.cos(2*np.pi*t)
    line,=ax1.plot(t,s,lw=2)
    bbox=dict(boxstyle='round',fc='white')
    ax1.annotate('local max',xy=(2,1),xytext=(3,1.5),
    arrowprops=dict(facecolor='black',edgecolor='red',headwidth=7,width=2),bbox=bbox)
    #arrowprops里面还有一些参数可选,arrowstyle箭头类型,arrowstyle="->",connectionstyle="arc3"指的是xy与xytext之间的连接类型
    bbox_prop=dict(fc='white')
    ax1.set_xlabel('asix-X',bbox=bbox_prop)
    #bbox再任何地方都可以使用,包括title里面都是可以使用的,他的意思就是添加方框,但是对方框进行修改的时候要使用字典形式
    #设置指示箭头的形状是通过字典来调节的,arrowprops字典,headwidth箭头头部的宽度,width箭头身子的宽度
    ax1.set_ylim(-2,2)
    ax1.text(1,1,'max')
    ax2=fig.add_subplot(122)
    ax2.set_ylim(-4,4)
    ax2.set_xlim(-4,4)
    bbox=dict(boxstyle='round',ec='red',fc='white')
    ax2.text(-2,0,'$y=sin(x)$',bbox=bbox)
    ax2.text(0,-2,'$y=cos(x)$',bbox=dict(boxstyle='square',facecolor='white',ec='black'),rotation=45)
    ax2.grid(ls=":",color='gray',alpha=0.5)
    #设置水印(带方框的水印)
    ax2.text(-2,2,'matplotlib',fontsize=20,alpha=0.3,color='gray',bbox=dict(fc="white",boxstyle='round',edgecolor='gray',alpha=0.3))
    plt.show()

  • 相关阅读:
    小程序上传多张图片
    小程序倒计时遇到的问题
    taro小程序展示富文本
    taro小程序地址选择组件
    构建基于Suricata+Splunk的IDS入侵检测系统
    SQL注入学习资料总结
    常见WAF绕过思路
    业务安全漏洞挖掘归纳总结
    细说验证码安全 —— 测试思路大梳理
    验证码安全那些事
  • 原文地址:https://www.cnblogs.com/shunguo/p/11397068.html
Copyright © 2020-2023  润新知