如何更改 matplotlib 颜色条标签的字体属性? [英] How to change font properties of a matplotlib colorbar label?

查看:37
本文介绍了如何更改 matplotlib 颜色条标签的字体属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在matplotlib中,我想更改 colorbar 标签的字体属性.例如,我希望标签显示为粗体.

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

这是一些示例代码:

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:

本网站上的所有其他答案仅回答如何更改 ticklabels 或更改所有字体(通过修改 matplotlibrc 文件)

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

推荐答案

这个两行可以与任何 Text 属性一起使用 (http://matplotlib.org/api/text_api.html#matplotlib.text.Text)

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')

这篇关于如何更改 matplotlib 颜色条标签的字体属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆