title: Make a heatmap of x,y,z data in Python
body: <p>I am trying to draw a heatmap in Python.
  I have studied several tutorials but still can't achieve what I need.
  My data has 3 columns: <strong>X</strong>, <strong>Y</strong> (coordinates in the scatterplot) and <strong>cluster</strong> (a group/cluster each row is placed). The desired output should look like that (6 clusters and X,Y points distributed in the coloured areas):</p>
  
  <p><a href="https://i.stack.imgur.com/oLCxQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oLCxQ.png" alt="enter image description here"></a></p>
  
  <p>My current code:</p>
  
  <pre><code># libraries
  import pandas as pd
  import matplotlib.pyplot as plt
  import numpy as np
  from scipy.stats import kde
  from scipy.interpolate import griddata
  
  # Get the data (csv file is hosted on the web)
  url = 'https://raw.githubusercontent.com/ampil/sandbox/master/latest-sales-sample.csv'
  df = pd.read_csv(url, sep = ';')
  df = df.dropna(axis=0, how='any', thresh=None, subset=None, inplace=False)
  # create data
  x = df['X']
  y = np.log(df['Y'])
  z = df['cluster']
  
  # target grid to interpolate to
  xi = yi = np.arange(0, 1.01, 0.01)
  xi, yi = np.meshgrid(xi,yi)
  
  # interpolate
  zi = griddata((x,y),z,(xi,yi),method='cubic')
  
  # plot
  fig = plt.figure()
  ax = fig.add_subplot(111)
  ax.axis((x.min(), x.max(), y.min(), y.max()))
  plt.contourf(xi, yi, zi, np.arange(0, 1.01, 0.01), cmap='coolwarm')
  plt.plot(x,y,'k.')
  plt.xlabel('x',fontsize=16)
  plt.ylabel('y',fontsize=16)
  plt.show()
  plt.close(fig)
  </code></pre>
  
  <p>gives me</p>
  
  <p><a href="https://i.stack.imgur.com/REk0z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/REk0z.png" alt="my graph"></a></p>
  
  <p>Later on, I plan to publish the graph via dash.</p>
  
  <p>Any help is appreciated!</p>