title: Filling matrix with array of coordinates in python
body: <p>I currently have 2 arrays corresponding to coordinates (X,Y) and a third array corresponding to the value at this point in 2d space. It is coded as such instead of being a matrix, since it is a pretty sparse matrix (not every point possesses a value). Now I want to reconstruct the matrix in order to plot the values with matplotlib.imshow(). </p>
  
  <p>So far, the easiest way I have is to do a for loop, like this:</p>
  
  <pre><code>X = [1, 1, 3, 5];
  Y = [2, 2, 3, 7];
  Z = [0.3, -0.5, 1, 1];
  matrix = np.zeros([10,10])
  
  for i in range(len(Z)):
      matrix[X[i],Y[i]] = Z[i]
  </code></pre>
  
  <p>I mean, it is not terrible, but I fear the big arrays. Is there a function that would take the 1st and 2nd inputs as the 1st and 2nd coordinates respectively with the 3rd input as the value at these coordinates? Or would there be something similar?</p>