pythonmatplotlib

How to change font properties of a matplotlib colorbar label?


In matplotlib, I want to change the font properties for a colorbar label. For example I want the label to appear bold.

Here is some example code:

from matplotlib.pylab import *
pcolor(arange(20).reshape(4,5))
cb = colorbar(label='a label')

and the result, where I want "a label" to appear bold:

output plot

All other answers on this site only answer how to change ticklabels or change all fonts in general (via modification of the matplotlibrc file)


Solution

  • This two-liner can be used with any Text property (http://matplotlib.org/api/text_api.html#matplotlib.text.Text)

    cb = plt.colorbar()
    cb.set_label(label='a label',weight='bold')