【发布时间】:2019-01-26 23:24:11
【问题描述】:
我在 Jupyter Notebook 中使用 Matplotlib 来显示地图图像。代码如下所示:
%matplotlib inline
imgpath = './map.png'
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
from PIL import Image
img = Image.open(imgpath)
print(img.size)
width, height = img.size
# img.thumbnail((width * 2,height * 2), Image.ANTIALIAS) # resizes image in-place
imgplot = plt.imshow(img)
plt.savefig('test.png', dpi = 300)
问题是,虽然plt.savefig('test.png', dpi = 300) 看起来不错(因为我将 dpi 更改为 300),但笔记本中显示的图像分辨率太低了,我无法在上面做任何事情,而 plt.imshow(img, dpi = 300) 没有工作:
所以我想知道是否有办法改变 Jupyter Notebook 中显示的图像的分辨率?
【问题讨论】:
-
你试过右键=>打开图片吗?它会打开它,您将获得更多详细信息。
-
谢谢,这确实使它稍微好一点,但仍然比理想的分辨率更小/更低。
标签: python matplotlib jupyter-notebook