I am trying to duplicate the following color bar with matplotlib. It is shown to the right of an image. Originally this color bar was produced in Matlab. However I think that I can define another axis to do the histogram but I have no idea how to start on making the color map change opacity above and below a threshold. Any idea where to start on this?