Bokeh-customising-legends

提供:Dev Guides
移動先:案内検索

ボケ-凡例のカスタマイズ

プロット内のさまざまなグリフは、凡例プロパティで識別できます。デフォルトでは、プロットエリアの右上にラベルとして表示されます。 この凡例は次の属性でカスタマイズできます-

1 legend.label_text_font change default label font to specified font name
2 legend.label_text_font_size font size in points
3 legend.location set the label at specified location.
4 legend.title set title for legend label
5 legend.orientation set to horizontal (default) or vertical
6 legend.clicking_policy specify what should happen when legend is clicked hide: hides the glyph corresponding to legend mute: mutes the glyph corresponding to legendtd>

凡例のカスタマイズのサンプルコードは次のとおりです-

from bokeh.plotting import figure, output_file, show
import math
x2 = list(range(1,11))
y4 = [math.pow(i,2) for i in x2]
y2 = [math.log10(pow(10,i)) for i in x2]
fig = figure(y_axis_type = 'log')
fig.circle(x2, y2,size = 5, color = 'blue', legend = 'blue circle')
fig.line(x2,y4, line_width = 2, line_color = 'red', legend = 'red line')
fig.legend.location = 'top_left'
fig.legend.title = 'Legend Title'
fig.legend.title_text_font = 'Arial'
fig.legend.title_text_font_size = '20pt'
show(fig)

出力

凡例のカスタマイズ