title: Python netcdf plot data onto grid
body: <p>I am using Lat, Lon data and would like to average all the sample_data within a grid cell (say 1km x 1km) uniformly across the whole area, and then plot it similar to this post, but with a basemap, I'm a bit stuck where to start: 
  <a href="https://stackoverflow.com/questions/25071968/heatmap-with-text-in-each-cell-with-matplotlibs-pyplot/25074150#25074150">Heatmap with text in each cell with matplotlib&#39;s pyplot</a></p>
  
  <p>The code below plots values through each time point, and I'd like to average the data within defined grid squares across the whole data area at each time point, and plot the average value onto the basemap with a grid at set time intervals (ie. make a set of images for a timelapse/movie). </p>
  
  <pre><code>import matplotlib.pyplot as plt
  from mpl_toolkits.basemap import Basemap
  from netCDF4 import Dataset
  import matplotlib.cm as cm
  
  data = Dataset(netcdf_data,'r')
  
  lat = data.variables['lat'][:]
  lon = data.variables['lon'][:]
  time = data.variables['time'][:]
  
  
  fig = plt.figure(figsize=(1800,1200))
  m = Basemap(projection='ortho',lon_0=5,lat_0=35,resolution='l')
  m.drawcoastlines()
  
  
  for value in range(0,len(sample_data)):
      m.plot(lat[:,value], lon[:,value], alpha=1, latlon=True)
  
  plt.show()
  </code></pre>