# リスト7.3.1:カラーネームによる色の設定
from bokeh.plotting import figure, output_notebook, show
output_notebook()
p = figure(plot_width=200, plot_height=200)
p.circle([0], [0], size=30, color="red")
show(p)
# リスト7.3.2:16進数カラーコードによる色の設定
p = figure(plot_width=200, plot_height=200)
p.circle([0], [0], size=30, color="#FF0000")
show(p)
# リスト7.3.3:RGBカラーコードによる色の設定
p = figure(plot_width=200, plot_height=200)
p.circle([0], [0], size=30, color=(255, 0, 0))
show(p)
# リスト7.3.4:オブジェクトの不透明度を設定
p = figure(plot_width=200, plot_height=200)
p.circle([0, 0.5, 1], [0, 0, 0], size=30, color=(0, 0, 255))
p.circle([0.25, 0.75], [0, 0], size=50, color=(255, 0, 0, 0.5))
show(p)
# リスト7.3.5:alphaによる透過設定
p = figure(plot_width=200, plot_height=200)
p.circle([0, 0.5, 1], [0, 0, 0], size=30, color="blue")
p.circle([0.25, 0.75], [0, 0], size=50, color="red", alpha=0.5)
show(p)
# リスト7.3.6:fill_colorを設定
p = figure(plot_width=200, plot_height=200)
p.circle([0], [0], size=30, fill_color="red", line_width=5)
show(p)
# リスト7.3.7:line_colorを設定
p = figure(plot_width=200, plot_height=200)
p.circle([0], [0], size=30, fill_color="red", line_color="black", line_width=5)
show(p)
# リスト7.3.8:Blues6を指定してインポート
from bokeh.palettes import Blues6
Blues6
['#08519c', '#3182bd', '#6baed6', '#9ecae1', '#c6dbef', '#eff3ff']
# リスト7.3.10:Bluesを指定してインポート
from bokeh.palettes import Blues
Blues
{3: ['#3182bd', '#9ecae1', '#deebf7'], 4: ['#2171b5', '#6baed6', '#bdd7e7', '#eff3ff'], 5: ['#08519c', '#3182bd', '#6baed6', '#bdd7e7', '#eff3ff'], 6: ['#08519c', '#3182bd', '#6baed6', '#9ecae1', '#c6dbef', '#eff3ff'], 7: ['#084594', '#2171b5', '#4292c6', '#6baed6', '#9ecae1', '#c6dbef', '#eff3ff'], 8: ['#084594', '#2171b5', '#4292c6', '#6baed6', '#9ecae1', '#c6dbef', '#deebf7', '#f7fbff'], 9: ['#08306b', '#08519c', '#2171b5', '#4292c6', '#6baed6', '#9ecae1', '#c6dbef', '#deebf7', '#f7fbff']}
# リスト7.3.12:Blues6による着色
p = figure(plot_width=200, plot_height=200, x_range=(0, 2), y_range=(-0.5, 5.5))
for i, color in enumerate(Blues6):
p.square(0.5, i, color=color, size=20)
p.text(1, i, text=[color], text_baseline="middle")
show(p)