728x90
plot_options = dict(width=250, plot_height=250, tools='pan, wheel_zoom')
s1 = figure(**plot_options) #플롯 옵션을 가져옴
s1.square(x, y1, size=10, color="red", alpha=0.5)
s2 = figure(x_range=s1.x_range, **plot_options) # s1의 x_range를 넣어서 연결되게 함
s2.square(x, y2, size=10, color="green", alpha=0.5)
s3 = figure(y_range=s1.y_range, **plot_options) # s1의 y_range를 넣어서 연결되게 함
s3.square(x, y3, size=10, color="blue", alpha=0.5)
p = gridplot([[s1, s2, s3]])
show(p)
s1의 x축을 움직이면 s3의 x축도 움직임
s1의 y축을 움직이면 s3의 y축도 움직임
x = list(range(-20, 21))
y1, y2 = [abs(i) for i in x], [i ** 2 for i in x]
source = ColumnDataSource(data=dict(x=x, y1=y1, y2=y2))
tools = "box_select,, lasso_select, help"
left = figure(tools=tools, width=300, height=300)
left.circle('x', 'y1', source=source)
right = figure(tools=tools, width=300, height=300)
right.circle('x', 'y2', source=source)
p = gridplot([[left, right]])
show(p)
선택한 영역이 공유가 됩니다.
from bokeh.models import HoverTool
source = ColumnDataSource(
data=dict(
x=np.random.randint(1, 10, 5),
y=np.random.randint(1, 10, 5),
desc=["A", "B", "C", "D", "E"],
)
)
hover = HoverTool(
tooltips=[
("index", "$index"),
("(x, y)", "($x, $y)"),
("desc", "@desc"),
]
)
p = figure(plot_width=300, plot_height=300, tools=[hover])
p.circle('x', 'y', size=20, source=source)
show(p)
.
'bokeh' 카테고리의 다른 글
[bokeh] 막대, 범주형 데이터 플롯 (Bar, Categorical Data Plots) (0) | 2020.10.05 |
---|---|
[bokeh] 위젯 (Widgets) (0) | 2020.10.05 |
[bokeh] 레이아웃 (Layout) (0) | 2020.10.05 |
[bokeh] 주석 (Annotations) (0) | 2020.10.05 |
[bokeh] 데이터 제공 (0) | 2020.10.05 |