如何更改 matplotlib.pyplot.colorbar.ColorbarBase 刻度的字体大小? [英] How do I change the font size of ticks of matplotlib.pyplot.colorbar.ColorbarBase?

查看:164
本文介绍了如何更改 matplotlib.pyplot.colorbar.ColorbarBase 刻度的字体大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何更改matplotlibColorbarBase 的刻度字体大小.以下几行是我的分析脚本中的相关部分,其中使用了 ColorbarBase.

I would like to know how to change the font size of ticks of ColorbarBase of matplotlib. The following lines are a relevant part in my analysis script, in which ColorbarBase is used.

import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
import matplotlib as mpl

axcb = fig.add_axes([0.9, 0.135, 0.02, 0.73])

cb = mpl.colorbar.ColorbarBase(axcb, norm=LogNorm(vmin=7e-5, vmax=1), cmap=plt.cm.CMRmap)
cb.set_label("Relative Photon Intensity", labelpad=-1, size=14)

我正在OS X上将 matplotlib 版本1.4.3和Python 2.7一起使用.

I am using matplotlib ver 1.4.3 with Python 2.7 on OS X.

推荐答案

您可以使用以下方法更改刻度大小:

You can change the tick size using:

font_size = 14 # Adjust as appropriate.
cb.ax.tick_params(labelsize=font_size)

在此处查看 文档,了解 ax.tick_params了解更多可以修改的参数.

See the docs for ax.tick_params here for more parameters that can be modified.

这篇关于如何更改 matplotlib.pyplot.colorbar.ColorbarBase 刻度的字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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