PDF python 绘图模糊 - 图像插值?

bpr*_*auf 5 python pdf interpolation latex matplotlib

我想将 python 生成的 pdf 绘图包含到Overleaf Latex 文档中。但图像显得模糊。下面是一个最小的例子。我用 imshow 生成了两张图,一张用interpolation='none',一张用interpolation='nearest'。使用的版本是Python 2.7.15matplotlib 2.2.3。

使用 pdf-viewer evince 3.20.2imshow_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 下都清晰的文件吗?

证据:imshow,插值='无'
Evince:imshow,插值='最近' 背面:imshow,插值='最近' 背页:imshow,插值='无'

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()
Run Code Online (Sandbox Code Playgroud)

乳胶代码:

\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}
Run Code Online (Sandbox Code Playgroud)