Reputation: 39
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 . 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
if I use p.xaxis.major_label_text_font_size = "12pt"
it just changes the x_ticks but not the group labels. Also, using p.xaxis.axis_label_text_font_size = "12pt"
does not seem to change anything. 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)
Upvotes: 0
Views: 639
Reputation: 11
If you look at all properties of axis here, you can find property group_text_font_size
.
That is exactly that you are looking for.
So, the code will be:
p.xaxis.group_text_font_size = "18pt" # for example
Upvotes: 1