# リスト7.9.1:軸の書式の設定
from bokeh.plotting import figure, output_notebook, show
output_notebook()
p = figure(plot_width=200, plot_height=200)
p.circle([0], [0])
p.xaxis.axis_label = "x"
p.yaxis.axis_label = "y"
p.xaxis.axis_label_text_color = "red"
p.axis.axis_line_width = 3 # X軸、Y軸両方に適用される
p.xaxis.axis_line_dash = "dashed"
p.xaxis.axis_label_standoff = 30
show(p)
# リスト7.9.2:軸の幅の設定
p = figure(plot_width=200, plot_height=200)
p.circle([0], [0])
p.yaxis.bounds = (-0.5, 0.5)
show(p)
# リスト7.9.3:目盛りの書式の設定
p = figure(plot_width=200, plot_height=200)
p.circle([0], [0])
p.xaxis.major_tick_line_width = 3
p.yaxis.major_tick_line_color = "red"
p.yaxis.minor_tick_line_color = "blue"
show(p)
# リスト7.9.4:目盛りラベルの書式設定
p = figure(plot_width=200, plot_height=200)
p.circle([0], [0])
p.xaxis.major_label_text_color = "red"
p.yaxis.major_label_text_font_size = "10pt"
show(p)
# リスト7.9.5:目盛りの長さ設定
p = figure(plot_width=200, plot_height=200)
p.circle([0], [0])
p.xaxis.major_tick_in = 15
p.xaxis.minor_tick_out = 5
p.yaxis.major_tick_in = 15 # inとoutは両方設定可能
p.yaxis.major_tick_out = 15 # inとoutは両方設定可能
p.yaxis.minor_tick_in = -10 # 負の整数も指定可能
show(p)
# リスト7.9.6:FixedTickerの設定
from bokeh.models import FixedTicker
p = figure(plot_width=200, plot_height=200)
p.circle([1, 1.5, 2.2, 3], [1, 2, 3, 4])
p.xaxis.ticker = FixedTicker(ticks=[1.5, 2.2])
p.yaxis.ticker = FixedTicker(ticks=[2, 3])
show(p)
# リスト7.9.7:NumeralTickFormatterの設定
from bokeh.models import NumeralTickFormatter
p = figure(plot_width=200, plot_height=200)
p.circle([0.123], [0.45])
p.xaxis.formatter = NumeralTickFormatter(format="0.00") # 小数点2桁までを表示
p.yaxis.formatter = NumeralTickFormatter(format="0.0%") # パーセント表示
show(p)
# リスト7.9.8:PrintTickFormatterの設定
from bokeh.models import PrintfTickFormatter
p = figure(plot_width=200, plot_height=200)
p.circle([0.123], [0.45])
p.xaxis.formatter = PrintfTickFormatter(format="%.2f") # 小数点2桁までを表示
p.yaxis.formatter = PrintfTickFormatter(format="%e") # 科学的記数法
show(p)
# リスト7.9.9:major_label_orientationの設定
p = figure(plot_width=200, plot_height=200)
p.circle([0], [0])
p.xaxis.major_label_orientation = 0.6
p.yaxis.major_label_orientation = "vertical"
show(p)