如何修改BOKEH条形图中的类别文本大小? [英] How to modify categories text size in BOKEH bar charts?

查看:78
本文介绍了如何修改BOKEH条形图中的类别文本大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在BOKEH条形图中修改不同类别文本(以黄色突出显示的文本)的大小失败.

如果有人知道如何实现这一目标,我将非常感激.

解决方案

诀窍是修改 CategoricalAxis 的文本尺寸,该尺寸位于下方图形对象(通常是第一项位于位置0).

要修改组的文本大小,请使用此行.

  p.below [0] .group_text_font_size ='13px' 

以相同的方式,您可以设置多个其他样式选项,例如 axis_label_text_font_size major_label_text_font_size 等.要查看其工作原理,请查看下面的示例.

演示

以下是bokeh中有关

现在,您可以对x轴下方的文本进行一些更改.

  p.below [0] .group_text_font_size ='16px'p.below [0] .group_text_font_style ='正常'p.below [0] .group_text_color ='黑色'p.below [0] .major_label_text_font_size ='14px'p.below [0] .major_label_text_color ='黑色' 

这将设置

  1. 组('16px')和标签('14px')的新字体大小,
  2. 用于组和标签的新字体颜色(此处为'black')和
  3. 组的新字体样式(此处为'normal').

该图现在看起来像这样:

I am unsuccessfully trying to modify the size of the text of the different categories (text highlighted in yellow) in a BOKEH bar-chart.

I would be really grateful if somebody knows how to achieve this.

解决方案

The trick is to modify the text size of the CategoricalAxis which is below the figure object (usually first item at position 0).

To modify the text size for groups, use this line.

p.below[0].group_text_font_size = '13px'

In the same way you can set multiple other styling options, like the axis_label_text_font_size or the major_label_text_font_size and many other. To see how it works, look at the example below.

Demonstration

Following the example from bokeh about Handling Categorical Data the output looks like this:

Now you can do some changes for the text below the x-axis.

p.below[0].group_text_font_size = '16px'
p.below[0].group_text_font_style = 'normal'
p.below[0].group_text_color = 'black'
p.below[0].major_label_text_font_size = '14px'
p.below[0].major_label_text_color = 'black'

This will set

  1. a new font size for groups ('16px') and labels ('14px'),
  2. a new font color for groups and labels (here 'black') and
  3. a new font style to the groups (here 'normal').

The figure looks now like this:

这篇关于如何修改BOKEH条形图中的类别文本大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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