# 导入模块from bokeh.plotting import figure, output_file, show
from bokeh.palettes import magma
import numpy as np
import random
c = np.random.randint(0,10, size=10)
d = np.random.randint(0,10, size=10)# 实例化图形对象
graph = figure(title="Bokeh Scatter Graph")# 读取数据库# data = pd.read_csv("tips.csv")
color = magma(256)# 绘制图形
graph.scatter(1,1, color=color)
graph.scatter(2,2, color=magma(100))
graph.scatter(3,3, color=magma(200))
graph.scatter(c, d, color=magma(np.random.randint(0,256)))# 展示模型
show(graph)
import numpy.random
from bokeh.plotting import figure, output_notebook, show
from bokeh.models import HoverTool
x = numpy.random.randn(500)
y = numpy.random.randn(500)
hover = HoverTool()
hover.tooltips =[("(x,y)","($x, $y)")]
p = figure(tools=[hover])
p.circle(x, y, color='red', size=14, alpha=0.4)
show(p)
from bokeh.plotting import figure, output_file, show
# output to static HTML file# output_file("line.html")# 创建画布
p = figure(plot_width=400, plot_height=400)# 根据x,y坐标绘制愿(大小、颜色、透明度)# p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5)# # add a square renderer with a size, color, and alpha# p.square([1, 2, 3, 4, 5], [1, 2, 3, 4, 5], size=20, color="olive", alpha=0.5)# x,y坐标点及线宽 单条折线
p.line([1,2,3,4,5],[6,7,2,4,5], line_width=2)# # add a steps renderer# p.step([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=2, mode="center")# 线段 或射线
p.segment(x0=[1,2,3], y0=[1,2,3], x1=[1.2,2.4,3.1],
y1=[1.2,2.5,3.7], color="#F4A582", line_width=3)# 显示绘制结果
show(p)
from bokeh.plotting import figure, show, output_file
p = figure(plot_width=400, plot_height=400)
p.vbar(x=[1,2,3], width=0.5, bottom=[0.1,0.2,0.3],
top=[1.2,2.5,3.7], color="firebrick")
show(p)