Linux 拨号vps windows公众号手机端

使用Rectangle函数怎么去边框

lewis 6年前 (2019-02-05) 阅读数 11 #程序编程
文章标签 Rectangle

要去掉Rectangle函数绘制的边框,可以通过设置边框的颜色为透明来实现。具体步骤如下:

  1. 导入绘图库
import matplotlib.pyplot as plt
  1. 创建一个矩形对象并设置边框颜色为透明
rect = plt.Rectangle((x, y), width, height, edgecolor='none')
  1. 将矩形对象添加到图形中
plt.gca().add_patch(rect)
  1. 显示图形
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()

这样就可以绘制一个没有边框的矩形图形。

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门