使用 python matplotlib 画矩形

版权声明:本文为博主原创文章,未经博主允许不得转载。Eddy_zheng https://blog.csdn.net/Eddy_zheng/article/details/52185380

1、绘制矩形

python matplotlib 绘制矩形,简单的几行代码就可以实现,简单易懂,方便利用。

# -*- coding: utf-8 -*-
"""
Created on Thu Aug 11 18:12:37 2016

@author: Eddy_zheng
"""

import matplotlib.pyplot as plt
import matplotlib.patches as patches

fig1 = plt.figure()
ax1 = fig1.add_subplot(111, aspect='equal')
ax1.add_patch(
    patches.Rectangle(
        (0.1, 0.1),   # (x,y)
        0.5,          # width
        0.5,          # height
    )
)
fig1.savefig('rect1.png', dpi=90, bbox_inches='tight')

这里写图片描述

猜你喜欢

转载自blog.csdn.net/Eddy_zheng/article/details/52185380