标签:
目标:利用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则把原图和绘制的矩形框一起保存下来。
标签:
原文地址:http://www.cnblogs.com/jianyingzhou/p/4639239.html