简体   繁体   English

调整 x_axis_label 或 y_axis_label 字体/字体大小(散景)

[英]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)?有没有办法在散景(0.70)中调整x_axis_labely_axis_label字体/字体大小? I am aware of a way to adjust title font size with the title_text_font_size property, with:我知道一种使用title_text_font_size属性调整标题字体大小的title_text_font_size

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. (使用<name> _text_font_size 的约定)来指示字体大小属性。 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?如果这不存在,有人可以就如何在 cofeescript + API 方面进行此类调整提供一些指示,以便可以为项目做出贡献吗? Thanks谢谢

Figure exposes xaxis and yaxis attributes that you can use for that. Figure 公开了可用于此目的的 xaxis 和 yaxis 属性。 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:您还可以通过axis属性同时调整 x 和 y 标签:

p.axis.axis_label_text_font_style = 'bold'

This is how you can change the axis label using CustomJS :这是使用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";
""")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM