1多边形
x=[1,2,2,1]
y=[1,1,2,5]
plt.fill(x, y,facecolor='g',alpha=0.5)
plt.show()
把点按顺序连接起来,构成封闭的区域并填充
2矩形
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111) #
rect = plt.Rectangle((0.1,0.2),0.4,0.3, color="red") # (0.1,0.2)为左下角的坐标,0.4,0.3为宽和高,负数为反方向,红色填充
ax.add_patch(rect)
plt.show()
网友评论