赞
踩
- # 创建画布和子图
- fig, ax = plt.subplots()
-
- # 去除 x 轴和 y 轴的边框线
- ax.spines['bottom'].set_visible(False)
- ax.spines['top'].set_visible(False)
- ax.spines['left'].set_visible(False)
- ax.spines['right'].set_visible(False)
-
- # 隐藏 x 轴和 y 轴的刻度线和刻度标签
- ax.xaxis.set_ticks([])
- ax.yaxis.set_ticks([])
-
- # 设置坐标轴范围
- ax.set_xlim([0, 10])
- ax.set_ylim([0, 10])
##====== ========== =================================================
## | Class Name Attrs
## | Arc3 ``arc3`` rad=0.0
## | Angle3 ``angle3`` angleA=90, angleB=0
=================================================
-
- # 绘制曲线
- x = [1, 2, 3, 4, 5]
- y = [2, 5, 4, 8, 1]
- ax.plot(x, y)
-
- # 添加弯曲箭头
- start = (2, 4) # 箭头起始点坐标
- end = (5, 10) # 箭头结束点坐标
-
- # 使用FancyArrow类绘制弯曲箭头
- arrow1 = FancyArrowPatch(start, end,
- connectionstyle='arc3, rad=-0.4', # 设置弯曲箭头的样式和曲率
- mutation_scale=10, # 控制箭头大小
- color="red")
-
- arrow2 = FancyArrowPatch(start, end,
- connectionstyle='angle3, angleA=-60, angleB=-10 ', # 设置弯曲箭头的样式和曲率
- mutation_scale=10, # 控制箭头大小
- color="blue")
-
-
- # 添加箭头到图中
- ax.add_patch(arrow1)
- ax.add_patch(arrow2)
-
- # 显示图形
- plt.pause(0.01)
-
ax.axis('equal')
## | angle : float, default: 0
## | Rotation in degrees anti-clockwise about *xy*.
- # 创建Rectangle对象,并添加到子图
- rectangle = Rectangle((0.2, 0.2), 0.6, 0.4, facecolor='blue',\
- edgecolor='black', \
- angle=45, \
- alpha=1)
- ax.add_patch(rectangle)
- # 创建Circle对象,并添加到子图
- circle = Circle((0.8, 0.8), 0.2, facecolor='red', edgecolor='black')
- ax.add_patch(circle)
- # 创建Ellipse对象,并添加到子图
- ellipse = Ellipse((0.5, 0.5), 0.4, 0.6, angle=45, facecolor='green', edgecolor='black')
- ax.add_patch(ellipse)
- # 创建Polygon对象,并添加到子图
- polygon = Polygon([[0.2, 0.7], [0.4, 0.9], [0.6, 0.7], [0.4, 0.5],\
- [0.3, 0.4]], closed=True, facecolor='yellow', edgecolor='black')
- ax.add_patch(polygon)
- # 创建Wedge对象,并添加到子图
- wedge = Wedge((0.3, 0.3), 0.4, 30, 270, facecolor='purple', edgecolor='black')
- ax.add_patch(wedge)
a.txt
1
2
3
4
5
6
7
8
9
10
b.txt
123
213
123
21
51
123
1245
21
12
4
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。