title: PDF python plot is blurry - image interpolation?
body: <p>I want to include a python-generated pdf plot into an <em>Overleaf</em> Latex document. However the image appears blurry. A minimal example is below. I generate two plots with imshow, one with <code>interpolation='none'</code>, one with <code>interpolation='nearest'</code>. Used versions are <em>Python 2.7.15</em> and <em>matplotlib 2.2.3.</em>  </p>
  
  <p>Using the pdf-viewer <em>evince 3.20.2</em>, <em>imshow_none.pdf</em> has perfectly sharp pixels, while imshow_nearest.pdf shows blurry pixel edges and also pixel sizes may be different. Within the Overleaf-built-in pdf viewer under <em>Firefox 52.5.0</em>, everything is vice versa, with the blurrying being worse. When downloading the compiled pdf from Overleaf, the situation is as when viewing the files under evince. Png screenshots and the overleaf latex file are found below.</p>
  
  <p>I am not an expert on interpolation. Do the pdf viewers use the matplotlib interpolation parameters or their own interpolation method? How comes once the blurry image is <em>imshow_none.pdf</em>, once <em>imshow_nearest.pdf</em>? Is the interpolation method somehow stored in the pdf? In the tags? How to read out this information? Any way to create a file that is sharp both under evince and Overleaf?</p>
  
  <p><a href="https://i.stack.imgur.com/eIGMl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eIGMl.png" alt="Evince: imshow, interpolation=&#39;none&#39;"></a><br>
  <a href="https://i.stack.imgur.com/fvUu4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fvUu4.png" alt="Evince: imshow, interpolation=&#39;nearest&#39;"></a>
  <a href="https://i.stack.imgur.com/Ag7En.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ag7En.png" alt="Overleaf: imshow, interpolation=&#39;nearest&#39;"></a>
  <a href="https://i.stack.imgur.com/5bB3b.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5bB3b.png" alt="Overleaf: imshow, interpolation=&#39;none&#39;"></a></p>
  
  <p><strong>Python code:</strong></p>
  
  <pre><code>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()
  </code></pre>
  
  <p><strong>Latex code:</strong></p>
  
  <pre><code>\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}
  </code></pre>