提问人:bproxauf 提问时间:1/18/2019 更新时间:1/18/2019 访问量:1685
PDF python 图模糊 - 图像插值?
PDF python plot is blurry - image interpolation?
问:
我想将 python 生成的 pdf 绘图包含在 Overleaf Latex 文档中。但是,图像看起来模糊。下面是一个最小的例子。我用 imshow 生成两个图,一个用 ,一个用 。使用的版本是 Python 2.7.15 和 matplotlib 2.2.3。interpolation='none'
interpolation='nearest'
使用 pdf-viewer evince 3.20.2,imshow_none.pdf具有非常清晰的像素,而imshow_nearest.pdf显示模糊的像素边缘,并且像素大小可能不同。在 Firefox 52.5.0 下的 Overleaf 内置 pdf 查看器中,一切都反之亦然,模糊更严重。从 Overleaf 下载编译的 pdf 时,情况与查看 evince 下的文件时一样。Png 屏幕截图和叶子乳胶文件在下面找到。
我不是插值方面的专家。pdf 查看器是否使用 matplotlib 插值参数或他们自己的插值方法?为什么一旦模糊的图像被imshow_none.pdf,一次imshow_nearest.pdf?插值方法是否以某种方式存储在 pdf 中?在标签中?如何读出此信息?有什么方法可以创建一个在 evince 和 Overleaf 下都很清晰的文件吗?
Python 代码:
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
print sys.version
print matplotlib.__version__
np.random.seed(100)
a = np.random.rand(100,50)
plt.imshow(a, cmap='binary', aspect='auto', interpolation='none', origin='lower')
plt.title('imshow, interpolation: none')
plt.savefig('/home/proxauf/test_pdf_plot_interpolation/imshow_none.pdf')
plt.close()
plt.imshow(a, cmap='binary', aspect='auto', interpolation='nearest', origin='lower')
plt.title('imshow, interpolation: nearest')
plt.savefig('/home/proxauf/test_pdf_plot_interpolation/imshow_nearest.pdf')
plt.close()
乳胶代码:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{float}
\begin{document}
\begin{figure}[H]
\centering
\includegraphics{imshow_none.pdf}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics{imshow_nearest.pdf}
\end{figure}
\end{document}
答: 暂无答案
评论
pcolormesh
ax.set_aspect(1)
rasterized=True