如何在python中绘制矩形?

Aks*_*kar -2 matplotlib python-3.x seaborn

我有4个点,想用它绘制矩形

  a=[0,0]
  b=[0,5]
  c=[7,0]
  d=[7,5]
Run Code Online (Sandbox Code Playgroud)

有没有办法使用matplotlib或seaborn绘制矩形?

Bra*_*mon 5

http://matthiaseisen.com/pp/patterns/p0203/

a=[0,0]
b=[0,5]
c=[7,0]
d=[7,5]
width = c[0] - a[0]
height = d[1] - a[1]
lims = (0, 10)

import matplotlib.pyplot as plt
import matplotlib.patches as patches
%matplotlib inline

fig1 = plt.figure()
ax1 = fig1.add_subplot(111, aspect='equal')
ax1.add_patch(
    patches.Rectangle((0, 0), width, height))
plt.ylim(lims)
plt.xlim(lims)
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明