码迷,mamicode.com
首页 > 编程语言 > 详细

python画图

时间:2015-07-11 19:58:40      阅读:442      评论:0      收藏:0      [点我收藏+]

标签:

目标:利用python在已有图的基础上画图

import matplotlib
matplotlib.use(‘Agg‘)
import matplotlib.pyplot as plt
from matplotlib.pyplot import savefig

%matplotlib inline

 

 #####clear the axis to show a new image.

currentAxis=plt.cla()

 

im=plt.imread(showimage)
plt.imshow(im)
currentAxis=plt.gca()

 

coords=((int(xmin),int(ymin)),width,height)
currentAxis.add_patch(plt.Rectangle(*coords,fill=False,edgecolor=‘g‘,linewidth=2))

savefig(savename,dpi=150)

 

按照这种模式,将图showimage显示出来,同时还可以将矩形框显示出来,当然也可以通过for循环将多个矩形框绘制在图上,而savefig则把原图和绘制的矩形框一起保存下来。

 

python画图

标签:

原文地址:http://www.cnblogs.com/jianyingzhou/p/4639239.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!