title: How to make a bi-variate or 2-dimension colormap with matplotlib?
body: <p>I am trying to make a geographical map with colors, in which the colors of pixels will depend on 2-dimensions of (x,y), like this one extracted from one publication:</p>
  
  <p><a href="https://i.stack.imgur.com/XFSgL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XFSgL.png" alt="Lowerleft corner is the 2-dimension colorbar legend whose color depends changes of two variables"></a></p>
  
  <p>I searched online and this is where I arrive:</p>
  
  <p><a href="https://gist.github.com/ChaoYue/81eb01b558f068f11ee741c56557a6a2" rel="nofollow noreferrer">https://gist.github.com/ChaoYue/81eb01b558f068f11ee741c56557a6a2</a></p>
  
  <p>To put it short, I know how to pick up color by x-axis value, and use y-axis value as an indicator of either saturation, or brightness or transparency of the color. Or somehow to convert this (x,y) information back to linear space and select color from a matplotlib colormap. But the question is, for example, suppose I want the color as lowerleft=blue,lowerright=green; upperleft=red,upperright=orange. How can I interpolate the color of pixels in between? Or maybe this example is in contradiction with color theory and it is not possible?  The equivalent question is: how can I make a colorbar legend like the figure shown in the above?</p>
  
  <p>These are the online sources that help me, but they don't directly give the instructions I am looking for:</p>
  
  <p><a href="https://stackoverflow.com/questions/15207255/is-there-any-way-to-use-bivariate-colormaps-in-matplotlib">Is there any way to use bivariate colormaps in matplotlib?</a></p>
  
  <p><a href="https://github.com/matplotlib/matplotlib/issues/4369" rel="nofollow noreferrer">https://github.com/matplotlib/matplotlib/issues/4369</a></p>