title: Plotting a 2D contour plot from binned xyz data
body: <p>EDIT: I responded in the comments but I've tried the method in the marked post - my z data is not calculated form my x and y so I can't use a function like that. </p>
  
  <p>I have xyz data that looks like the below:</p>
  
  <p><a href="https://i.stack.imgur.com/dp6Ss.png" rel="nofollow noreferrer">NEW:the xyz data in the file i produce - I extract these as x,y,z</a></p>
  
  <p>And am desperately trying to get a plot that has x against y with z as the colour.</p>
  
  <p>y is binned data that goes from (for instance) 2.5 to 0.5 in uneven bins. So the y values are all the same for one set of x and z data. The x data is temperature and the z is density info. </p>
  
  <p>So I'm expecting a plot that looks like a bunch of stacked rectangles where there is a gradient of colour for one bin of y values which spans lots of x values.</p>
  
  <p>However all the codes I've tried don't like my z values and the best I can do is:</p>
  
  <p><a href="https://i.stack.imgur.com/JVDhr.png" rel="nofollow noreferrer">The axes look right but the colour bar goes from the bottom to the top of the y axis instead of plotting one z value for each x value at the correct y value</a></p>
  
  <p>I got this to work with this code: </p>
  
  <pre><code>import matplotlib.cm as cm
  from matplotlib.colors import LogNorm
  import numpy as np
  import scipy.interpolate
  data=pandas.read_csv('Data.csv',delimiter=',', header=0,index_col=False)
  x=data.tempbin
  y=data.sizefracbin
  z=data.den
  x=x.values
  y=y.values
  z=z.values
  X,Y=np.meshgrid(x,y)
  Z=[]
  for i in range(len(x)):
      Z.append(z)
  Z=np.array(Z)
  plt.pcolormesh(X,Y,Z)
  plt.colorbar()
  plt.show()
  </code></pre>
  
  <p>I've tried everything I could find online such as in the post here: <a href="https://stackoverflow.com/questions/39727040/matplotlib-2d-plot-from-x-y-z-values">matplotlib 2D plot from x,y,z values</a></p>
  
  <p>But either there is a problem reshaping my z values or it just gives me empty plots with various errors all to do (I think) with my z values.</p>
  
  <p>Am I missing something? Thank you for your help!</p>
  
  <p>Edit in reponse to : ImportanceOfBeingErnest</p>
  
  <p>I tried this :</p>
  
  <pre><code>import matplotlib.cm as cm
  from matplotlib.colors import LogNorm
  import numpy as np
  import scipy.interpolate
  data=pandas.read_csv('Data.csv',delimiter=',', header=0,index_col=False)
  data.sort_values('sizefrac')
  x=data.tempbin
  y=data.sizefrac
  z=data.INP
  x=x.values
  y=y.values
  z=z.values
  X=x[1:].reshape(N,N)
  Y=y[1:].reshape(N,N)
  Z=z[1:].reshape(N,N)
  plt.pcolormesh(X,Y,Z)
  plt.colorbar()
  plt.show()
  </code></pre>
  
  <p>and got a very empty plot. Just showed me the axes and colourbar as in my attached image but pure white inside the axes! No error or anything...
  And the reshaping I need to remove a data point from each because otherwise the reshaping won't work</p>