title: Matplotlib: using colormap to show regime (axvspan or bar?)
body: <p>I'm trying to represent one dataset as blocks of color in my plot (instead of showing as a variable width bar chart i would like to show this as a variable width block with a background color.)</p>
  
  <p>I could do something like this:</p>
  
  <pre><code>import numpy
  import matplotlib.pyplot as plt
  import matplotlib.cm as cm
  import matplotlib.colors as colors        
  
  # Create fake data
  x = numpy.linspace(0,4)
  y = numpy.exp(x)
  
  # Now plot one by one
  bar_width = x[1] - x[0]  # assuming x is linealy spaced
  for pointx, pointy in zip(x,y):
      point = 40
      current_color = cm.jet( min(pointy/30, 30)) # maximum of 30
      plt.bar(pointx, point, bar_width, color = current_color)       
  
  plt.show()
  </code></pre>
  
  <p>But then i do not have scaling of the colormap to the extent of my data.</p>
  
  <p>Or i could do something like:</p>
  
  <pre><code>for i in range(10):
      color = cm.jet(min(i/30, 30))
      plt.axvspan(i, i+1, facecolor=color, alpha=0.5)
  </code></pre>
  
  <p>But again this is unsatisfactory as i would like to have a way to have my data autoscaled to cmap's min and max.</p>
  
  <p>Thanks!</p>