Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PDF python绘图模糊-图像插值?_Python_Pdf_Matplotlib_Latex_Interpolation - Fatal编程技术网

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

PDF python绘图模糊-图像插值?,python,pdf,matplotlib,latex,interpolation,Python,Pdf,Matplotlib,Latex,Interpolation,我想将python生成的pdf绘图包含到背面的Latex文档中。但是,图像看起来很模糊。下面是一个简单的例子。我使用imshow生成了两个绘图,一个使用interpolation='none',一个使用interpolation='nearest'。使用的版本是Python 2.7.15和matplotlib 2.2.3 使用pdf viewer evince 3.20.2,imshow_none.pdf具有非常清晰的像素,而imshow_nearest.pdf显示模糊的像素边缘,并且像素大小可

我想将python生成的pdf绘图包含到背面的Latex文档中。但是,图像看起来很模糊。下面是一个简单的例子。我使用imshow生成了两个绘图,一个使用
interpolation='none'
,一个使用
interpolation='nearest'
。使用的版本是Python 2.7.15和matplotlib 2.2.3

使用pdf viewer evince 3.20.2,imshow_none.pdf具有非常清晰的像素,而imshow_nearest.pdf显示模糊的像素边缘,并且像素大小可能不同。在Firefox 52.5.0下的内置pdf查看器的背面,一切都是相反的,模糊更糟糕。从背面下载已编译的pdf时,情况与查看evince下的文件时相同。Png截图和背面的latex文件如下所示

我不是插值专家。pdf查看器使用matplotlib插值参数还是自己的插值方法?如果模糊的图像是imshow\u none.pdf,如果是imshow\u nearest.pdf,怎么会出现这种情况?插值方法是否以某种方式存储在pdf中?在标签里?如何读出这些信息?有什么方法可以创建一个文件,无论是在显示还是在背面都很清晰


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}
乳胶代码:

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}

相关:。感谢您的链接。它非常有用:)有没有办法告诉哪个pdf阅读器强制进行“最近的”插值?因为python生成的“最近的”图像在使用Evence查看时仍然模糊。不确定,这取决于pdf阅读器。也许在处理苹果特定问题的网站上提问?如果你使用
pcolormesh
(和
ax.set\u aspect(1)
,如果需要的话),我认为图像不会模糊。您可能希望光栅化pcolor(
rasterized=True
在KWARG列表中)。