Jonathan Shore
Jonathan Shore

Reputation: 920

adjusting x_axis_label or y_axis_label font/font size (Bokeh)

Is there a way to adjust x_axis_label and y_axis_label font/font size in Bokeh (0.70)? I am aware of a way to adjust title font size with the title_text_font_size property, with:

figure (..., title_text_font_size="12pt")

Is there a way to then specify something like:

figure (..., x_axis_label_text_font_size='10pt')

(using the convention of <name>_text_font_size) to indicate the font size property. The above did not work. If this is not present, could someone give some pointers as to how to make this sort of adjustment in the cofeescript + API-side of things, so can contribute back to the project? Thanks

Upvotes: 12

Views: 15350

Answers (2)

Fabio Pliger
Fabio Pliger

Reputation: 696

Figure exposes xaxis and yaxis attributes that you can use for that. In your use case it should be able to use:

p.xaxis.axis_label = 'whatever'
p.xaxis.axis_label_text_font_size = "40pt"

You can also adjust x and y labels simultaneously via the axis attribute:

p.axis.axis_label_text_font_style = 'bold'

Upvotes: 28

tuomastik
tuomastik

Reputation: 4906

This is how you can change the axis label using CustomJS:

p = figure(x_axis_label="Initial y-axis label",
           y_axis_label="Initial x-axis label")

# ...

# p.xaxis and p.yaxis are lists. To operate on actual the axes,
# we need to extract them from the lists first.
callback = CustomJS(args=dict(xaxis=p.xaxis[0],
                              yaxis=p.yaxis[0]), code="""
    xaxis.axis_label = "Updated x-axis label";
    yaxis.axis_label = "Updated y-axis label";
""")

Upvotes: 0

Related Questions