欢迎来到代码驿站!

Python代码

当前位置:首页 > 软件编程 > Python代码

python matplotlib 注释文本箭头简单代码示例

时间:2021-08-10 09:25:37|栏目:Python代码|点击:

注释文本箭头

结果展示:

完整代码示例:

import numpy as np
import matplotlib.pyplot as plt

fig, ax = plt.subplots(figsize=(5, 5))
ax.set_aspect(1)

x1 = -1 + np.random.randn(100)
y1 = -1 + np.random.randn(100)
x2 = 1. + np.random.randn(100)
y2 = 1. + np.random.randn(100)

ax.scatter(x1, y1, color="r")
ax.scatter(x2, y2, color="g")

bbox_props = dict(boxstyle="round", fc="w", ec="0.5", alpha=0.9)
ax.text(-2, -2, "Sample A", ha="center", va="center", size=20,
    bbox=bbox_props)
ax.text(2, 2, "Sample B", ha="center", va="center", size=20,
    bbox=bbox_props)


bbox_props = dict(boxstyle="rarrow", fc=(0.8, 0.9, 0.9), ec="b", lw=2)
t = ax.text(0, 0, "Direction", ha="center", va="center", rotation=45,
      size=15,
      bbox=bbox_props)

bb = t.get_bbox_patch()
bb.set_boxstyle("rarrow", pad=0.6)

ax.set_xlim(-4, 4)
ax.set_ylim(-4, 4)

plt.show()

总结

以上就是本文关于python matplotlib 注释文本箭头简单代码示例的全部内容,希望对大家有所帮助。感兴趣的朋友可以继续参阅本站:

matplotlib绘制动画代码示例

python+matplotlib绘制简单的海豚(顶点和节点的操作)

Python通过matplotlib画双层饼图及环形图简单示例

如有不足之处,欢迎留言指出。感谢朋友们对本站的支持!

上一篇:python requests完成接口文件上传的案例

栏    目:Python代码

下一篇:Django视图扩展类知识点详解

本文标题:python matplotlib 注释文本箭头简单代码示例

本文地址:http://www.codeinn.net/misctech/165796.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有