您的位置:首页 > 编程语言 > Python开发

python画图

2015-07-11 19:44 746 查看
目标:利用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则把原图和绘制的矩形框一起保存下来。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: