title: Python: Compute Bin-Mean Value of Scatter Plot Bullets
body: <p>I have three 1D arrays (A, B, C) of equal length/size. I plot a scatter plot of B vs. A where I color each scatter plot bullet by the corresponding value in the C array (see the code below).</p>
  
  <pre><code># Imports
  import matplotlib.cm as cm
  import matplotlib.colors as colors
  import matplotlib as mpl
  import matplotlib.pyplot as plt
  import numpy as np
  
  # Create the Arrays
  A = 10 * np.random.random_sample((20, 20))
  B = 10 * np.random.random_sample((20, 20))
  C = 100 * np.random.random_sample((20, 20))
  
  A = A.reshape(20*20)
  B = B.reshape(20*20)
  C = C.reshape(20*20)
  
  # Create the Colormap and Define Boundaries
  cmap_C = cm.jet
  cmap_C.set_bad(color='white')
  bounds_C =  np.arange(0, 110, 10)
  norm_C = mpl.colors.BoundaryNorm(bounds_C, cmap_C.N)
  
  # Plot the Figure
  plt.figure()
  plt.scatter(A, B, c=C, marker='o', s=100, cmap=cmap_C, norm=norm_C)
  plt.xlim([-1, 11])
  plt.ylim([-1, 11])
  plt.xticks(np.arange(0, 11, 1))
  plt.yticks(np.arange(0, 11, 1))
  plt.xlabel('A')
  plt.ylabel('B')
  plt.grid()
  plt.colorbar(label='Value of C')
  plt.show()
  </code></pre>
  
  <p>Some bullets overlap in the figure so we cannot see them clearly. Therfore, next I now want to compute and plot the mean C value of all scatter plot bullets within each 1 integer x 1 integer bin in the figure so that each square grid point is colored by one single color (these bins are illustrated by the figure gridding). How can I do this?</p>