要去掉Rectangle函数绘制的边框,可以通过设置边框的颜色为透明来实现。具体步骤如下:
import matplotlib.pyplot as plt
rect = plt.Rectangle((x, y), width, height, edgecolor='none')
plt.gca().add_patch(rect)
plt.show()
完整代码示例:
import matplotlib.pyplot as plt
x = 0 # 矩形左下角 x 坐标
y = 0 # 矩形左下角 y 坐标
width = 5 # 矩形宽度
height = 3 # 矩形高度
rect = plt.Rectangle((x, y), width, height, edgecolor='none')
plt.gca().add_patch(rect)
plt.show()
这样就可以绘制一个没有边框的矩形图形。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: 使用Rectangle函数如何去除它的框