title: Python: Delaunay triangle vertices don't "line up" when saved as .pdf or .png
body: <p>I created a set of Delaunay triangles using scipy.spatial.</p>
  
  <pre><code>from matplotlib import pyplot as plt
  import matplotlib
  from skimage import io
  from scipy.spatial import Delaunay
  import numpy as np
  from PIL import Image
  from scipy.ndimage import rotate
  
  h = 700
  w = 700
  npts = 500
  pts = np.zeros((npts,2))
  pts[:,0] = np.random.randint(0,w,npts)
  pts[:,1] = np.random.randint(0,h,npts)
  
  tri = Delaunay(pts)
  centers = np.sum(pts[tri.simplices], axis=1, dtype='int')/3.0
  
  #plt.figure()
  fig, ax = plt.subplots()
  plt.xlim(0, w)
  plt.ylim(0, h)
  
  
  for i in range(0,len(pts[tri.simplices])-1):
      temp_tri = plt.Polygon(pts[tri.simplices][i], color = colors[i]/256) #colors variable is a numpy.ndarray variable that contains RGB values
      plt.gca().add_patch(temp_tri)
  
  plt.gca().set_aspect('equal')
  plt.axis('off')
  
  plt.savefig('test.pdf', bbox_inches = 'tight', dpi=fig.dpi)
  plt.show()
  </code></pre>
  
  <p>On the screen, the output is as I intended. However, when I save it as pdf or png, the vertices of Delaunay triangles do not match (they do when I look at them through plt.show()) </p>
  
  <p>The picture below is part of the whole picture, just to highlight where the vertices don't match.</p>
  
  <p><a href="https://i.stack.imgur.com/T3nfC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/T3nfC.png" alt="Delaunay triangles with vertices that do not match."></a></p>
  
  <p>Few suggestions I found with issues regarding different images shown with plt.show() and fitsave() said I should match the dpi, which I have done. </p>
  
  <p>Please advise on what I should try. Thank you so much in advance!</p>