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则把原图和绘制的矩形框一起保存下来。
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则把原图和绘制的矩形框一起保存下来。
相关文章推荐
- Python3.x安装第三方库的方法 欢迎使用CSDN-markdown编辑器
- php exec python script not working [Solved]
- python 处理时间
- python module package import
- python比较两个列表大小的方法
- python实现计算倒数的方法
- Python上下文管理器
- Python项目五: 虚拟茶话会
- python学习笔记——循环语句条件语句
- 浅谈 Python 的 with 语句
- python实现基本进制转换的方法
- 流动python - 自然装饰
- python计算圆周率pi的方法
- python计算一个序列的平均值的方法
- 给你的python安个窝
- 12步轻松搞定python装饰器
- python 生成排列、组合以及选择
- python常用函数(一)
- Python学习笔记—itertools模块
- python修改字典内key对应值的方法