title: Why does the filesize of a matplotlib plot saved as .eps with rasterization explode?
body: <p>I have the following demonstration code where I create a simple scatter plot and save it as <code>png</code>, fully vectorized <code>eps</code> and partly rasterized <code>eps</code>.</p>
  
  <p>For a large number of points I expect the filesize of the vectorized <code>eps</code> to be much bigger than the <code>png</code> (at least at reasonable dpi), and this is indeed what I observe.
  When I rasterize the scatter plot, I would expect the filesize to get back down towards the size of the <code>png</code>, since I'm practically just "embedding" the png in an <code>eps</code>, right? However, the rasterized version completely bloats up by a factor of ~20: </p>
  
  <p><code>png</code>: 48K, fully vectorized <code>eps</code>: 184K, rasterized <code>eps</code>: 3.8M (on Linux openSUSE, <code>python 3.4.6</code>, <code>matplotlib 2.2.2</code>)</p>
  
  <p>What's the reason for this? Is my understanding of what happens when one rasterizes the plot completely wrong? When I put the <code>png</code> into inkscape and export as <code>eps</code> I get a file (which is obviously rasterized) of only minutely larger size than the original <code>png</code>.</p>
  
  <p>Demonstration code:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import numpy as np
  
  # Prepare some random data
  N = 10000
  x = np.random.rand(N)
  y = np.random.rand(N)
  
  dpi = 150
  
  # Create a figure and plot some points
  fig = plt.figure()
  ax = fig_mesh.add_subplot(111)
  
  scatter = ax.scatter(x, y, zorder=0.5)
  
  # Save it as png or unrasterized eps
  fig_mesh.savefig('mesh.png', dpi=dpi) # 184K
  fig_mesh.savefig('mesh.eps') # 48 K
  
  # Save it with rasterized points
  ax_mesh.set_rasterization_zorder(1)
  fig_mesh.savefig('mesh_rasterized.eps', dpi=dpi, rasterized=True) # 3.8M!
  </code></pre>
  
  <p>Thanks in advance!</p>