Colorbar plot with matplotlib ... but in gray?

matplotlib, python, scipy

Solution

The colorbar shows the colormap used for the data. If you want different colors, specify a different colormap in your `matshow` call:

ax.matshow(newcm, cmap=pyplot.cm.Greys)

You can see available colormaps at http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps . There a couple grayscale options.

Problem

Is it possible to change the colors of the colorbar plot to grayscale ? At the moment I plot them like this: ``` ax = fig.add_subplot(326,title='Title') cax = ax.matshow(newcm) fig.colorbar(cax) ax.set_xticklabels(['']+alpha) ax.set_yticklabels(['']+alpha) pl.show() ``` Though off course they appear in color. But is it possible to change them to grayscale ? And how ?

Original source