Hello, I am trying to generate on the fly a non linear rainbow colorbar as in picture Colorbar below.
I use a slider to automatically modify the aspect of the colorbar (see code below). This works fine except that I want to have a different behaviour of the colorbar when moving the slider: My wish is to have the limits of the colorbar remain fixed (cmin and cmax), but the rainbow range should be shrinked (though the tick label of the colorbar should not be modified). I am seaching around using matplotlib.colors.LinearSegmentedColormap without any success. Should in this case the colormap be completly re created each time the slider moves, or is it possible using any kwargs to automatically change the behaviour of the colorbar as I wanted ? Many thanks in advance for any help... See example below, where the colorbar cmax limit is changed, whereas I wanted that it remains fixed and the shape of the colorbar rainbow decreases. from matplotlib.pylab import * import matplotlib.pyplot as plt from matplotlib.widgets import Slider sizeX = 4 sizeY = 21 dims = ( sizeY, sizeX ) data = zeros( dims ) for x in range( 0, sizeX ): for y in range( 0, sizeY ): data[ y, x ] = y figure = plt.figure() axes = figure.add_subplot( 111 ) figure.subplots_adjust(left=0.25, bottom=0.25) cax = axes.matshow( data, aspect = 'auto', interpolation = 'nearest' ) col = figure.colorbar( cax, spacing='proportional', extend='min' ) vmax = 50 axmax = figure.add_axes([0.25, 0.15, 0.65, 0.03], axisbg='lightgoldenrodyellow') smax = Slider( axmax, 'Max', 0, vmax, valinit = vmax ) cax.set_clim( vmin = 0, vmax = vmax ) def update(val): cax.set_clim( vmin = 0, vmax = smax.val ) figure.canvas.draw() smax.on_changed( update ) http://old.nabble.com/file/p31602280/Colorbar.png Colorbar.png -- View this message in context: http://old.nabble.com/Creating-non-linear-colorbar-Colorbar-tp31602280p31602280.html Sent from the matplotlib - users mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Achieve unprecedented app performance and reliability What every C/C++ and Fortran developer should know. Learn how Intel has extended the reach of its next-generation tools to help boost performance applications - inlcuding clusters. http://p.sf.net/sfu/intel-dev2devmay _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users