我有4分,想用它绘制矩形
a=[0,0]
b=[0,5]
c=[7,0]
d=[7,5]
有没有办法用matplotlib或seaborn绘制矩形?
答案 0 :(得分:3)
来自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)