2014-12-10 4 views
8

Wie lege ich die Schriftgröße für eine Figur fest, wenn ich Bokeh verwende?Titelschriftgröße für eine Bokeh-Figur anpassen

Ich habe versucht (in ipython Notebook):

import bokeh.plotting as bp 
import numpy as np 
bp.output_notebook() 

x_points = np.random.rand(100) 
y_points = np.random.rand(100) 

bp.figure(title='My Title', x_axis_label='X axis', y_axis_label='Y axis', \ 
    text_font_size='8pt') 

bp.scatter(x_points, y_points) 
bp.show() 

ich text_font_size habe versucht, label_text_font, title_font_size usw. Wo in der Dokumentation all dieser Informationen ist?

Antwort

8

Ich fand es heraus. Sie müssen ‚title_‘ auf ‚text_font_size‘

import bokeh.plotting as bp 
import numpy as np 
bp.output_notebook() 

x_points = np.random.rand(100) 
y_points = np.random.rand(100) 

bp.figure(title='My Title', x_axis_label='X axis', y_axis_label='Y axis', \ 
    title_text_font_size='8pt') 

bp.scatter(x_points, y_points) 
bp.show() 
+0

Warum 'bokeh' erfordern Schrift haben' pt' drauf? –

9

Grundstück Objekt title_text_font_size wurde in 0.12.0 veraltet und werden entfernt vorangestellt wird. Ab Bokeh-Version 0.12.0 sollte stattdessen Plot.title.text_font_size verwendet werden. Aktualisiert Beispiel ist unten:

import numpy as np 
import bokeh.plotting as bp 

bp.output_notebook() 

x_points = np.random.rand(100) 
y_points = np.random.rand(100) 

p = bp.figure(title='My Title', x_axis_label='X axis', y_axis_label='Y axis') 

p.title.text_font_size = '8pt' 

p.scatter(x_points, y_points) 
bp.show(p) 

Sie können die Schriftgröße ähnlich der Achsenbeschriftungen ändern:

p.xaxis.axis_label_text_font_size = "20pt" 
p.yaxis.axis_label_text_font_size = "20pt" 
Verwandte Themen