[英]How to set the x axis group names font size in Bokeh?
I'm trying to set the x axis font size for a nested barplot with bokeh but i can't find the right way (or any way) to do it.我正在尝试为带有散景的嵌套条形图设置 x 轴字体大小,但我找不到正确的方法(或任何方法)。 I been using pretty much the template for the fruits graph in bokeh gallery with a few variations.我一直在使用散景画廊中的水果图模板,但有一些变化。
https://docs.bokeh.org/en/latest/docs/gallery/bar_dodged.html https://docs.bokeh.org/en/latest/docs/gallery/bar_dodged.html
if I use p.xaxis.major_label_text_font_size = "12pt"
it just changes the x_ticks but not the group labels.如果我使用p.xaxis.major_label_text_font_size = "12pt"
它只会更改 x_ticks 但不会更改组标签。 Also, using p.xaxis.axis_label_text_font_size = "12pt"
does not seem to change anything.此外,使用p.xaxis.axis_label_text_font_size = "12pt"
似乎没有任何改变。 Im quite lost at this point.在这一点上我很迷茫。
Here is my code, thanks!这是我的代码,谢谢!
from bokeh.io import output_file, show
from bokeh.models import ColumnDataSource, FactorRange
from bokeh.plotting import figure
from bokeh.transform import factor_cmap
output_file("bar_stacked.html")
#output_notebook()
diagnosis = ["one", "two", "three"]
datos = ["I", "D", "C"]
data = {'Diagnosis' : diagnosis,
'I' : [332, 272, 187],
'D' : [600, 302, 174],
'C' : [859, 552, 263]}
palette = ["#c9d9d3", "#718dbf", "#e84d60"]
x = [(diag, dato) for diag in diagnosis for dato in datos]
counts = sum(zip(data['I'], data['D'], data['C']), ()) # like an hstack
source = ColumnDataSource(data=dict(x=x, counts=counts))
p = figure(x_range=FactorRange(*x), plot_height=450,
toolbar_location=None, tools="")
p.vbar(x='x', top='counts', width=0.9, source=source,line_color="white",
fill_color=factor_cmap('x', palette=palette, factors=datos, start=1, end=2) )
p.y_range.start = 0
p.x_range.range_padding = 0.1
p.xaxis.major_label_orientation = 1
p.xgrid.grid_line_color = None
p.title.text = "Data available by Diagnosis"
p.title.text_font_size = "14pt"
p.title.align = 'center'
p.title.text_font ="ubuntu"
p.xaxis.axis_label_text_font_size = "12pt"
p.xaxis.major_label_text_font_size = "9pt"
p.xaxis.major_label_orientation = 3/4
p.xaxis.major_label_text_font = "ubuntu"
#p.xaxis.major_label_text_font_style = "bold"
p.yaxis.major_label_text_font_size = "12pt"
p.yaxis.axis_label_text_font = "ubuntu"
#p.yaxis.axis_label_text_color = "black"
#p.legend.label_text_font_size = '30pt'
show(p)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.