title: matplotlib pcolormesh discrete colors
body: <pre><code>from matplotlib.pyplot import *
  import numpy as np
  
  x      = np.linspace( 1., 4., 2 )
  y      = np.linspace( 1., 2., 2 )
  x,y    = np.meshgrid( x, y )
  z      = np.array( [ [ 0.5, 1.5 ], [ 2.5, 3.5 ] ] )
  cmap   = matplotlib.colors.ListedColormap( [ 'r', 'y', 'g', 'b' ] )
  bounds = [ 0.,  1.,  2.,  3.,  4. ]
  ticks  = [ 0.5, 1.5, 2.5, 3.5 ]
  norm   = matplotlib.colors.BoundaryNorm( bounds, cmap.N )
  fig    = figure( figsize = ( 20, 10 ) )
  ax     = fig.add_subplot( 111 )
  ax.pcolormesh( x, y, z, cmap = cmap, norm = norm )
  ax.axis( [ x.min(), x.max(), y.min(), y.max() ] )
  ax.set_xlabel( 'x' )
  ax.set_ylabel( 'y' )
  m      = cm.ScalarMappable( cmap = cmap )
  m.set_array( z )
  cbar   = fig.colorbar( m, norm = norm, boundaries = bounds, aspect = 20, ticks = ticks )
  cbar.set_ticklabels( [ 'A', 'B', 'C', 'D' ] )
  show()
  </code></pre>
  
  <p>According to the values of <strong><code>z</code></strong> I would like to have a 4-field colormesh. As the first <code>z</code>-entry  0.5 is in the interval [ 0., 1. ], I want it to be <strong><code>red</code></strong>, the second <strong><code>yellow</code></strong> and so on.</p>
  
  <p>The colorbar displays already perfectly what I want to, but the plot itself is wrong.</p>
  
  <p><strong>Maybe I got something wrong with the BoundaryNorm?</strong></p>