调整散景图的标题字体大小

时间:2014-12-10 16:22:54

标签: python-2.7 bokeh

使用散景时如何设置数字的标题字体大小?

我试过(在ipython笔记本中):

import bokeh.plotting as bp
import numpy as np
bp.output_notebook()

x_points = np.random.rand(100)
y_points = np.random.rand(100)

bp.figure(title='My Title', x_axis_label='X axis', y_axis_label='Y axis', \
    text_font_size='8pt')

bp.scatter(x_points, y_points)
bp.show()

我尝试过text_font_size,label_text_font,title_font_size等。 文档中的所有信息都在哪里?

2 个答案:

答案 0 :(得分:16)

Plot属性title_text_font_size在0.12.0中已弃用,将被删除。从散景版0.12.0开始,应该使用Plot.title.text_font_size代替。更新的示例如下:

import numpy as np
import bokeh.plotting as bp

bp.output_notebook()

x_points = np.random.rand(100)
y_points = np.random.rand(100)

p = bp.figure(title='My Title', x_axis_label='X axis', y_axis_label='Y axis')

p.title.text_font_size = '8pt'

p.scatter(x_points, y_points)
bp.show(p)

您可以类似地更改轴标签的字体大小:

p.xaxis.axis_label_text_font_size = "20pt"
p.yaxis.axis_label_text_font_size = "20pt"

答案 1 :(得分:10)

我明白了。你需要预先添加标题_'到' text_font_size'

import bokeh.plotting as bp
import numpy as np
bp.output_notebook()

x_points = np.random.rand(100)
y_points = np.random.rand(100)

bp.figure(title='My Title', x_axis_label='X axis', y_axis_label='Y axis', \
    title_text_font_size='8pt')

bp.scatter(x_points, y_points)
bp.show()