Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Colorbar plot with matplotlib ... but in gray?

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 ?

like image 772
Olivier_s_j Avatar asked Sep 12 '26 11:09

Olivier_s_j


1 Answers

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.

like image 74
BrenBarn Avatar answered Sep 15 '26 01:09

BrenBarn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!