title: How can I obtain a contour plot and a 3D plot using Matplotlib starting from a set of 3 columns representing x,y and z points?
body: <p>I have a data file in which there are 3 columns representing the x, y and z values. The  z points are derived from a relation between x and y (so for each couple x[i]y[i] there is a z[i]). I'd like, using Matplotlib, to obtain a contour plot and coloring the surface by z values and then similarly a 3D plot. In lot of examples I've seen that it's possible to use numpy to meshgrid x and y (something that I cannot do because the huge amount of data) and then define z as f(x,y) but, as I said, I already have the z values for x and y.
  With GnuPlot is quite simple do that but in this case I cannot really understand how it does.
  Can you please help? Thank you in advance</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  import matplotlib.pyplot as plt
  
  data=pd.read_csv('data.dat')
  x=np.array(data.iloc[:,0])
  y=np.array(data.iloc[:,1])
  z=np.array(data.iloc[:,2])
  
  contour = plt.tricontour(x, y, z, 20, colors='k', extent=[min(x), max(x), min(y), max(y)], origin='lower', alpha=0.3) #obtain contour plot
  
  plt.imshow(z, extent=[min(x), max(x), min(y), max(y)], origin='lower') #of course here comes the error about the shape of z
  </code></pre>