栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在matplotlib中缩放图像而不更改轴

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在matplotlib中缩放图像而不更改轴

最后,我遵循了tcaswell的建议,并使用了2个不同的轴。这样,我只需要使用

set_xlim()
和调整
set_ylim()
图像轴,即可更改图像的原点和/或缩放比例。我要获得图的下方的图像,而不用图的框架隐藏它,而是删除了图的框架,改用图像轴的框架。我还隐藏了图像轴上的刻度线。

from matplotlib import pyplotf = pyplot.figure()a = f.add_subplot(111, frameon=False) # Remove framea.plot(...)myimg = pyplot.imread(...)imgaxes = f.add_axes(a.get_position(), # new axes with same position    label='image', # label to ensure imgaxes is different from a    zorder=-1, # put image below the plot    xticks=[], yticks=[]) # remove the ticksimg = imgaxes.imshow(myimg, aspect='auto') # ensure image takes all the place# now, to modify thingsimg.set_alpha(...)imgaxes.set_xlim((x1, x2)) # x1 and x2 must be calculated from     # image size, origin, and zoom factor


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/646600.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号