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

在ipython中更改imshow的分辨率

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

在ipython中更改imshow的分辨率

屏幕上显示图像的高度和宽度由图形尺寸和轴尺寸控制。

figure(figsize = (10,10)) # creates a figure 10 inches by 10 inches

轴数

axes([0,0,0.7,0.6]) # add an axes with the position and size specified by          # [left, bottom, width, height] in normalized units.

较大的数据数组将以与较小的数组相同的大小显示,但是单个元素的数量将更多,因此从某种意义上讲,它们确实具有更高的分辨率。可以使用savefig的dpi参数控制已保存图形的分辨率(以每英寸点数为单位)。

这是一个可能更清楚的示例:

import matplotlib.pyplot as pltimport numpy as npfig1 = plt.figure() # create a figure with the default sizeim1 = np.random.rand(5,5)ax1 = fig1.add_subplot(2,2,1) ax1.imshow(im1, interpolation='none')ax1.set_title('5 X 5')im2 = np.random.rand(100,100)ax2 = fig1.add_subplot(2,2,2)ax2.imshow(im2, interpolation='none')ax2.set_title('100 X 100')fig1.savefig('example.png', dpi = 1000) # change the resolution of the saved image

# change the figure sizefig2 = plt.figure(figsize = (5,5)) # create a 5 x 5 figure ax3 = fig2.add_subplot(111)ax3.imshow(im1, interpolation='none')ax3.set_title('larger figure')plt.show()

图形中轴的大小可以通过几种方式控制。我在上面使用了子图。您也可以直接添加一个轴的轴或gridspec。



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

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

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