当前位置:首页>python>Python 交互式可视化|Bokeh 保姆级速查指南

Python 交互式可视化|Bokeh 保姆级速查指南

  • 2026-06-28 01:22:07
Python 交互式可视化|Bokeh 保姆级速查指南
还在只会用 Matplotlib 画静态图?想要制作可缩放、可平移、可框选、带悬浮提示的网页交互式图表,那就一定要掌握 Bokeh!Bokeh 是 Python 中非常适合做交互式可视化的工具。它最大的特点是:代码相对简洁,图表可以直接生成 HTML 网页,并且支持缩放、拖动、框选、悬浮提示、多图联动等交互功能。对于数据分析、课程展示、论文辅助图表、可视化报告、数据大屏和公众号知识分享来说,都非常实用。本文整理了一份适合小白入门的 Bokeh 速查指南,从基本绘图逻辑、画布设置、数据源管理、常见图形绘制,到多图布局、坐标轴联动和 SVG 导出,一篇帮你快速入门。
一、什么是 Bokeh?
Bokeh 是 Python 中常用的交互式可视化库
如果说 Matplotlib 更擅长绘制静态图表,那么 Bokeh 更擅长绘制可以在网页中操作的动态图表。
Bokeh 的主要特点包括:
  • ✅ 支持网页交互图表
  • ✅ 支持缩放、平移、框选、点选
  • ✅ 支持悬浮提示,鼠标放到数据点上可以显示详细信息
  • ✅ 支持 HTML 输出,方便网页展示和分享
  • ✅ 支持折线图、散点图、柱状图、多图布局等常见图表
  • ✅ 可以和 Pandas、NumPy 配合使用
  • ✅ 支持 PNG、SVG 等格式导出,但需要额外环境配置
简单来说,Bokeh 适合用来做“能动起来、能交互、能网页展示”的 Python 图表。
二、Bokeh 绘图的基本思路
Bokeh 绘图可以记住一个万能流程:
导入工具 → 准备数据 → 创建画布 → 绘制图形 → 输出展示
下面是一个最基础、可以直接运行的 Bokeh 折线图示例:
from bokeh.plotting import figure, showfrom bokeh.io import output_filex= [12345]y= [67245]p= figure(title="基础示例图表",x_axis_label="横轴 X",y_axis_label="纵轴 Y",width=600,height=400)p.line(x, y,legend_label="数据曲线",line_width=2)output_file("lines.html")show(p)
这段代码运行后,会生成一个名为 `lines.html` 的网页文件,并在浏览器中打开图表。
逐行理解一下:
`from bokeh.plotting import figure, show` 表示导入 Bokeh 中最常用的两个工具。`figure()` 用来创建图表画布,`show()` 用来显示图表。
`from bokeh.io import output_file` 表示导入输出 HTML 文件的工具。
`x= [1, 2, 3, 4, 5]` 是横坐标数据。
`y= [6, 7, 2, 4, 5]` 是纵坐标数据。
`p= figure(...)` 表示创建一张图表。这里的 `p` 可以理解为一张“画布”。
`title="基础示例图表"` 设置图表标题。
`xaxislabel="横轴 X"` 设置横坐标名称。
`yaxislabel="纵轴 Y"` 设置纵坐标名称。
`width=600` 和 `height=400` 设置图表的宽度和高度。注意,Bokeh 3.x 推荐使用 `width` 和 `height`,不要再使用旧版的 `plotwidth` 和 `plotheight`。
`p.line(x, y,legendlabel="数据曲线",linewidth=2)` 表示在图表中绘制一条折线。
`legend_label="数据曲线"` 表示图例名称。
`line_width=2` 表示线条宽度为 2。
`output_file("lines.html")` 表示把图表保存成网页文件。
`show(p)` 表示显示图表。
三、为什么有时候 figure() 不显示图片?
很多初学者会写出这样的代码:
from bokeh.plotting import figurep1= figure(width=500,height=350,tools="pan,box_zoom,box_select,reset,save")p2= figure(width=500,height=400,x_range=(08),y_range=(08),title="固定范围图表")p3= figure()
这段代码本身没有错,但它不会显示图形。
原因很简单:这三行只是创建了三个空白画布 `p1`、`p2`、`p3`,还没有真正画任何东西,也没有使用 `show()` 显示出来。
可以把它理解成:你新建了三张白纸,但还没有在纸上画线、画点、画柱子,也没有把纸拿出来展示。
如果想让图表显示出来,需要增加绘图语句和显示语句:
from bokeh.plotting import figure, showfrom bokeh.layouts import rowfrom bokeh.io import output_filep1= figure(width=500,height=350,tools="pan,box_zoom,box_select,reset,save",title="图1:折线图")p1.line([1234], [2537],line_width=2,legend_label="折线")p2= figure(width=500,height=400,x_range=(08),y_range=(08),title="图2:固定范围散点图")p2.scatter([12345], [24365],size=12,color="red",legend_label="散点")p3= figure(width=500,height=350,title="图3:柱状图")p3.vbar(x=[1234],top=[3648],width=0.5,legend_label="柱状图")layout= row(p1, p2, p3)output_file("三图布局.html")show(layout)
这里 `p1.line()` 是画折线,`p2.scatter()` 是画散点,`p3.vbar()` 是画柱状图。
`row(p1, p2, p3)` 表示把三张图横向排列。
`show(layout)` 表示显示整个多图布局。
四、Bokeh 的画布 Figure 基础设置
Bokeh 中最核心的对象就是 `figure()`。它负责创建图表画布。
常见设置包括:图表标题、宽度、高度、坐标轴范围、工具栏等。
例如:
from bokeh.plotting import figure, showfrom bokeh.io import output_filep= figure(title="画布设置示例",width=600,height=400,x_axis_label="X轴",y_axis_label="Y轴",x_range=(010),y_range=(010),tools="pan,wheel_zoom,box_zoom,box_select,reset,save")p.line([12345], [2, 5, 4, 7, 6],line_width=2)output_file("figure_setting.html")show(p)
这里需要特别注意 `tools` 参数。Bokeh 的工具栏名称必须写英文,不能写中文。
正确写法是:
tools="pan,wheel_zoom,box_zoom,box_select,reset,save"
不能写成:
tools="平移,框选缩放"
常用工具说明如下:
工具名
作用
`pan`
平移图表
`wheel_zoom`
鼠标滚轮缩放
`box_zoom`
框选区域放大
`box_select`
框选数据点
`tap`
点击选择
`reset`
重置图表
`save`
保存图表
五、ColumnDataSource:Bokeh 的标准数据源
在 Bokeh 中,`ColumnDataSource` 是非常重要的数据格式。它可以把 Pandas 表格转换成 Bokeh 能识别的数据源,后面绘图时可以直接使用列名。
这对小白来说非常方便,因为我们做数据分析时,经常会用 Pandas 处理表格数据。
示例代码如下:
import pandas as pdfrom bokeh.plotting import figure, showfrom bokeh.io import output_filefrom bokeh.models import ColumnDataSourcedf= pd.DataFrame({"油耗": [33.932.421.425.828.1],"气缸": [44468],"马力": [6566109120150],"产地": ["US","Asia","Europe","US","Asia"]})source= ColumnDataSource(df)p= figure(title="ColumnDataSource 示例",width=600,height=400,x_axis_label="油耗",y_axis_label="马力")p.scatter("油耗","马力",source=source,size=14,color="blue",alpha=0.6)output_file("column_data_source.html")show(p)
这段代码中:
`df= pd.DataFrame({...})` 创建一个 Pandas 表格。
表格中有四列:油耗、气缸、马力、产地。
`source= ColumnDataSource(df)` 把 Pandas 表格转换成 Bokeh 专用数据源。
`p.scatter("油耗","马力",source=source, ...)` 表示横坐标使用“油耗”这一列,纵坐标使用“马力”这一列。
这样写的好处是代码更清晰,尤其适合表格型数据。
六、常用图形一:折线图 line()
折线图适合展示趋势变化,比如时间序列、指标变化、政策前后变化等。
from bokeh.plotting import figure, showfrom bokeh.io import output_filex= [20192020202120222023]y= [0.450.480.530.600.67]p= figure(title="折线图示例",width=600,height=400,x_axis_label="年份",y_axis_label="指标值")p.line(x,y,line_width=2,color="blue",legend_label="指标趋势")p.scatter(x,y,size=10,color="blue")p.legend.location="top_left"output_file("line_chart.html")show(p)
这里同时使用了 `p.line()` 和 `p.scatter()`。
`p.line()` 负责画线。
`p.scatter()` 负责在线上添加数据点。
这样图表会更清楚,读者既能看到趋势,也能看到每个年份的具体点位。
七、常用图形二:散点图 scatter()
散点图适合展示两个变量之间的关系,比如油耗和马力、收入和消费、城市规模和能源效率等。
from bokeh.plotting import figure, showfrom bokeh.io import output_filex= [33.932.421.425.828.1]y= [6566109120150]p= figure(title="散点图示例",width=600,height=400,x_axis_label="油耗",y_axis_label="马力",tools="pan,wheel_zoom,box_select,reset,save")p.scatter(x,y,size=14,color="green",alpha=0.7,legend_label="样本点")p.legend.location="top_left"output_file("scatter_chart.html")show(p)
参数解释:
`size=14` 表示散点大小。
`color="green"` 表示散点颜色为绿色。
`alpha=0.7` 表示透明度为 0.7,数值越小越透明。
`legend_label="样本点"` 表示图例名称。
八、常用图形三:柱状图 vbar()
柱状图适合做类别比较,比如不同地区、不同年份、不同组别的指标对比。
from bokeh.plotting import figure, showfrom bokeh.io import output_filecategories= ["A地区","B地区","C地区","D地区"]values= [23453156]p= figure(x_range=categories,title="柱状图示例",width=600,height=400,x_axis_label="地区",y_axis_label="数值")p.vbar(x=categories,top=values,width=0.5,color="orange",legend_label="指标值")p.legend.location="top_left"output_file("bar_chart.html")show(p)
这里的 `vbar()` 表示竖向柱状图。
`x=categories` 表示柱子对应的类别。
`top=values` 表示每根柱子的高度。
`width=0.5` 表示柱子的宽度。
如果想画横向柱状图,可以使用 `hbar()`。
九、常用图形四:多条折线 multi_line()
多条折线适合对比不同组别的变化趋势。
需要注意,`multi_line()` 不能随便写成:
p.multi_line(数据表, 数据表,color="blue")
这是错误写法。
正确写法是:传入多组 x 数据和多组 y 数据。
from bokeh.plotting import figure, showfrom bokeh.io import output_filexs= [[20192020202120222023],[20192020202120222023],[20192020202120222023]]ys= [[0.450.480.530.600.67],[0.400.430.470.510.58],[0.350.380.410.460.52]]p= figure(title="多条折线图示例",width=600,height=400,x_axis_label="年份",y_axis_label="指标值")p.multi_line(xs,ys,color=["blue","green","red"],line_width=2)output_file("multi_line_chart.html")show(p)
`xs` 是多条线的横坐标数据。
`ys` 是多条线的纵坐标数据。
第一组 `xs[0]` 会对应第一组 `ys[0]`,第二组 `xs[1]` 会对应第二组 `ys[1]`,以此类推。
十、选中高亮效果
Bokeh 的一大优势是可以交互式选择数据。比如用鼠标框选某些点,被选中的点可以变色,未选中的点可以变淡。
import pandas as pdfrom bokeh.plotting import figure, showfrom bokeh.io import output_filefrom bokeh.models import ColumnDataSourcedf= pd.DataFrame({"油耗": [33.932.421.425.828.1],"气缸": [44468],"马力": [6566109120150],"产地": ["US","Asia","Europe","US","Asia"]})source= ColumnDataSource(df)p= figure(title="选中高亮示例",width=600,height=400,x_axis_label="油耗",y_axis_label="气缸",tools="box_select,pan,wheel_zoom,reset,save")p.scatter("油耗","气缸",source=source,size=14,color="blue",selection_color="red",nonselection_alpha=0.1)output_file("selection_chart.html")show(p)
这里最关键的是:
`tools="boxselect,pan,wheelzoom,reset,save"` 开启框选工具。
`selection_color="red"` 表示被选中的点显示为红色。
`nonselection_alpha=0.1` 表示没有被选中的点透明度变为 0.1。
十一、分类颜色自动映射
如果数据里有不同类别,比如产地包括 `US`、`Asia`、`Europe`,可以让不同类别自动显示不同颜色。
注意:Bokeh 的颜色不能写“蓝色”“红色”“绿色”这种中文名称,要写英文颜色名或十六进制颜色值。
正确写法是:
["blue""red""green"]
或者:
["#1f77b4""#d62728""#2ca02c"]
完整示例:
import pandas as pdfrom bokeh.plotting import figure, showfrom bokeh.io import output_filefrom bokeh.models import ColumnDataSourcefrom bokeh.transform import factor_cmapfrom bokeh.palettes import Category10df= pd.DataFrame({"油耗": [33.932.421.425.828.130.5],"气缸": [444686],"马力": [6566109120150130],"产地": ["US","Asia","Europe","US","Asia","Europe"]})source= ColumnDataSource(df)factors= ["US","Asia","Europe"]p= figure(title="分类颜色映射示例",width=600,height=400,x_axis_label="油耗",y_axis_label="气缸")p.scatter("油耗","气缸",source=source,size=14,color=factor_cmap("产地",palette=Category10[3],factors=factors),legend_field="产地")p.legend.location="top_right"output_file("category_color_chart.html")show(p)
这里的 `factor_cmap()` 会根据“产地”这一列自动分配颜色。
`legend_field="产地"` 表示根据“产地”字段自动生成图例。
十二、悬浮提示 HoverTool
悬浮提示是 Bokeh 非常实用的功能。鼠标移动到数据点上时,可以显示该数据点的详细信息。
import pandas as pdfrom bokeh.plotting import figure, showfrom bokeh.io import output_filefrom bokeh.models import ColumnDataSourceHoverTooldf= pd.DataFrame({"油耗": [33.932.421.425.828.1],"气缸": [44468],"马力": [6566109120150],"产地": ["US","Asia","Europe","US","Asia"]})source= ColumnDataSource(df)p= figure(title="悬浮提示示例",width=600,height=400,x_axis_label="油耗",y_axis_label="马力",tools="pan,wheel_zoom,box_select,reset,save")p.scatter("油耗","马力",source=source,size=14,color="navy",alpha=0.6)hover= HoverTool(tooltips=[("油耗","@油耗"),("马力","@马力"),("气缸","@气缸"),("产地","@产地")])p.add_tools(hover)output_file("hover_tool_chart.html")show(p)
这里的 `HoverTool` 用于设置鼠标悬浮时显示的信息。
`("@油耗")` 表示读取数据源中“油耗”这一列的值。
`("@马力")` 表示读取数据源中“马力”这一列的值。
只要数据来自 `ColumnDataSource`,就可以用 `@列名` 的方式读取对应字段。
十三、图例美化设置
图例可以帮助读者快速理解不同线条、颜色、点代表什么含义。
from bokeh.plotting import figure, showfrom bokeh.io import output_filex= [12345]y1= [25867]y2= [13456]p= figure(title="图例美化示例",width=600,height=400)p.line(x, y1,line_width=2,color="blue",legend_label="数据 A")p.line(x, y2,line_width=2,color="red",legend_label="数据 B")p.legend.location="bottom_left"p.legend.orientation="vertical"p.legend.border_line_color="navy"p.legend.background_fill_color="white"output_file("legend_chart.html")show(p)
`p.legend.location="bottom_left"` 表示图例放在左下角。
`p.legend.orientation="vertical"` 表示图例垂直排列。
`p.legend.borderlinecolor="navy"` 设置图例边框颜色。
`p.legend.backgroundfillcolor="white"` 设置图例背景颜色。
常见图例位置包括:
参数
含义
`top_left`
左上角
`top_right`
右上角
`bottom_left`
左下角
`bottom_right`
右下角
`center`
中间
十四、多图布局:横向、纵向、网格
Bokeh 可以把多张图组合到一个页面中,非常适合做可视化报告。
1. 横向排列 row()
from bokeh.plotting import figure, showfrom bokeh.layouts import rowfrom bokeh.io import output_filep1= figure(width=300,height=300,title="图1:折线图")p1.line([123], [149],line_width=2)p2= figure(width=300,height=300,title="图2:散点图")p2.scatter([123], [321],size=12)p3= figure(width=300,height=300,title="图3:柱状图")p3.vbar(x=[123],top=[253],width=0.5)layout= row(p1, p2, p3)output_file("row_layout.html")show(layout)
`row(p1, p2, p3)` 表示三张图横向排列。
2. 纵向排列 column()
from bokeh.plotting import figure, showfrom bokeh.layouts import columnfrom bokeh.io import output_filep1= figure(width=500,height=300,title="上方图表")p1.line([123], [149],line_width=2)p2= figure(width=500,height=300,title="下方图表")p2.scatter([123], [321],size=12)layout= column(p1, p2)output_file("column_layout.html")show(layout)
`column(p1, p2)` 表示两张图纵向排列。
3. 网格布局 gridplot()
from bokeh.plotting import figure, showfrom bokeh.layouts import gridplotfrom bokeh.io import output_filep1= figure(width=300,height=300,title="折线图")p1.line([123], [149],line_width=2)p2= figure(width=300,height=300,title="散点图")p2.scatter([123], [321],size=12)p3= figure(width=300,height=300,title="柱状图")p3.vbar(x=[123],top=[253],width=0.5)layout= gridplot([[p1, p2], [p3, None]])output_file("grid_layout.html")show(layout)
`gridplot([[p1, p2], [p3, None]])` 表示第一行放 `p1` 和 `p2`,第二行放 `p3`,右下角空着。
十五、标签页切换 Tabs
如果图表比较多,也可以做成标签页切换。
Bokeh 3.x 中推荐使用 `TabPanel` 和 `Tabs`。
from bokeh.plotting import figure, showfrom bokeh.models import TabPanelTabsfrom bokeh.io import output_filep1= figure(width=500,height=300,title="折线图")p1.line([123], [149],line_width=2)p2= figure(width=500,height=300,title="散点图")p2.scatter([123], [321],size=12)tab1= TabPanel(child=p1,title="折线图")tab2= TabPanel(child=p2,title="散点图")tabs= Tabs(tabs=[tab1, tab2])output_file("tabs_layout.html")show(tabs)
这样生成的网页中会有两个标签页,一个显示折线图,一个显示散点图。
十六、坐标轴联动
坐标轴联动适合多图对比分析。比如两张图使用同一个横轴和纵轴范围,缩放其中一张图时,另一张图也会同步变化。
from bokeh.plotting import figure, showfrom bokeh.layouts import columnfrom bokeh.io import output_filep1= figure(width=600,height=300,title="图1:原始趋势",tools="pan,wheel_zoom,reset,save")p1.line([12345], [25867],line_width=2)p2= figure(width=600,height=300,title="图2:共享坐标轴",x_range=p1.x_range,y_range=p1.y_range,tools="pan,wheel_zoom,reset,save")p2.scatter([12345], [25867],size=12,color="red")layout= column(p1, p2)output_file("linked_axes.html")show(layout)
关键在这两句:
x_range=p1.x_rangey_range=p1.y_range
这表示 `p2` 和 `p1` 共享坐标轴范围。
因此,当你缩放或平移第一张图时,第二张图也会跟着变化。
十七、Bokeh 的导出方式
Bokeh 最推荐、最稳定的导出方式是 HTML,因为它可以保留图表交互功能。
1. 导出 HTML 网页
from bokeh.plotting import figure, showfrom bokeh.io import output_filep= figure(title="HTML 导出示例",width=600,height=400)p.line([123], [4, 5, 6],line_width=2)output_file("图表.html")show(p)
生成的 `图表.html` 可以直接用浏览器打开,也可以作为网页交互图表分享。
2. 在 Jupyter Notebook 中显示
from bokeh.plotting import figure, showfrom bokeh.io import output_notebookoutput_notebook()p= figure(title="Notebook 显示示例",width=600,height=400)p.line([123], [4, 5, 6],line_width=2)show(p)
`output_notebook()` 表示在 Jupyter Notebook 内部直接显示图表。
3. 导出 PNG 图片
from bokeh.plotting import figurefrom bokeh.io import export_pngp= figure(title="PNG 导出示例",width=600,height=400)p.line([123], [4, 5, 6],line_width=2)export_png(p,filename="图表.png")
注意:导出 PNG 通常需要安装 `selenium`,并且电脑上需要有可用的浏览器环境。
4. 导出 SVG 矢量图
from bokeh.plotting import figurefrom bokeh.io import export_svgsp= figure(title="SVG 导出示例",width=600,height=400)p.output_backend="svg"p.line([123], [4, 5, 6],line_width=2)export_svgs(p,filename="图表.svg")
这里一定要注意:
p.output_backend="svg"
这句非常重要。没有它,Bokeh 可能无法找到可以导出的 SVG 图形。
十八、为什么导出 SVG 会报错?
很多人运行下面代码时会报错:
export_svgs(p,filename="图表.svg")
常见报错是:
ModuleNotFoundErrorNo module named'selenium'
这说明你的 Python 环境里没有安装 `selenium`。
Bokeh 导出 PNG 或 SVG 时,需要借助浏览器把图表渲染出来,再导出为图片或矢量图。因此,除了 Bokeh 本身,还需要额外依赖。
解决方法是在 Anaconda Prompt 或终端中安装:
conda install selenium
或者:
pip install selenium
安装完成后,需要重启 Jupyter Notebook 内核,再重新运行导出代码。
如果安装 `selenium` 后仍然报错,可能是浏览器或浏览器驱动环境没有配置好。一般来说,先确认自己电脑上安装了 Chrome、Edge 或 Firefox 浏览器。
对于新手来说,最稳妥的方式是:优先导出 HTML。如果确实需要 SVG,再配置 `selenium` 环境。
十九、完整综合示例
下面这段代码整合了 Bokeh 中最常用的功能:表格数据、分类颜色、悬浮提示、框选高亮、图例和 HTML 输出。适合初学者直接运行学习。
import pandas as pdfrom bokeh.plotting import figure, showfrom bokeh.io import output_filefrom bokeh.models import ColumnDataSourceHoverToolfrom bokeh.transform import factor_cmapfrom bokeh.palettes import Category10df= pd.DataFrame({"油耗": [33.932.421.425.828.130.5],"气缸": [444686],"马力": [6566109120150130],"产地": ["US","Asia","Europe","US","Asia","Europe"]})source= ColumnDataSource(df)factors= ["US","Asia","Europe"]p= figure(title="Bokeh 交互式散点图综合示例",width=700,height=450,x_axis_label="油耗",y_axis_label="马力",tools="pan,wheel_zoom,box_select,reset,save")p.scatter("油耗","马力",source=source,size=16,alpha=0.7,color=factor_cmap("产地",palette=Category10[3],factors=factors),legend_field="产地",selection_color="red",nonselection_alpha=0.15)hover= HoverTool(tooltips=[("油耗","@油耗"),("马力","@马力"),("气缸","@气缸"),("产地","@产地")])p.add_tools(hover)p.legend.location="top_left"p.legend.title="产地分类"p.legend.border_line_color="gray"p.legend.background_fill_color="white"output_file("Bokeh交互式散点图.html")show(p)
这段代码实现了:
  • ✅ 使用 Pandas 创建表格数据
  • ✅ 使用 ColumnDataSource 管理数据
  • ✅ 使用散点图展示变量关系
  • ✅ 不同产地自动显示不同颜色
  • ✅ 鼠标悬浮显示详细信息
  • ✅ 支持框选数据
  • ✅ 被选中的点变红,未选中的点变淡
  • ✅ 自动生成 HTML 交互式网页图表
二十、Bokeh 常见错误总结
1. 只创建 figure,不会自动显示图形
错误理解:
p= figure()
这只是创建画布,不会显示图形。
正确做法:
p.line([1, 2, 3][4, 5, 6])show(p)
2. tools 不能写中文
错误写法:
tools="平移,框选缩放"
正确写法:
tools="pan,box_zoom,box_select,reset,save"
3. 颜色不能写中文
错误写法:
color="蓝色"
正确写法:
color="blue"
或者:
color="#1f77b4"
4. Bokeh 3.x 不建议使用 plotwidth 和 plotheight
旧写法:
figure(plot_width=600,plot_height=400)
推荐写法:
figure(width=600,height=400)
5. multi_line() 不能随便写“数据表”
错误写法:
p.multi_line(数据表, 数据表,color="blue")
正确写法:
p.multi_line(xs, ys,color=["blue","green","red"],line_width=2)
其中 `xs` 和 `ys` 都应该是二维列表。
6. SVG 导出需要设置 output_backend
错误写法:
export_svgs(p,filename="图表.svg")
推荐写法:
p.output_backend="svg"export_svgs(p,filename="图表.svg")
7. PNG 和 SVG 导出需要 selenium
如果报错:
ModuleNotFoundErrorNo module named'selenium'
说明需要安装:
conda install selenium
或者:
pip install selenium
二十一、Bokeh 学习小结
Bokeh 的核心逻辑其实并不复杂。
只要记住下面这条主线:
准备数据 → 创建 figure → 绘制图形 → 添加交互 → 输出 HTML
初学者可以先掌握以下几个高频函数:
函数
作用
`figure()`
创建图表画布
`line()`
绘制折线图
`scatter()`
绘制散点图
`vbar()`
绘制竖向柱状图
`ColumnDataSource()`
管理表格数据
`HoverTool()`
添加悬浮提示
`row()`
横向排列多图
`column()`
纵向排列多图
`gridplot()`
网格排列多图
`output_file()`
输出 HTML 文件
`show()`
显示图表
`export_png()`
导出 PNG 图片
`export_svgs()`
导出 SVG 矢量图
对于小白来说,最推荐的学习路径是:
先学会画一张基础折线图,再学会散点图和柱状图,然后掌握 `ColumnDataSource`,最后学习悬浮提示、多图布局和导出功能。
Bokeh 最适合的输出方式是 HTML,因为它可以完整保留交互效果。如果只是想做公众号展示,也可以截图使用;如果想做可编辑矢量图,可以尝试 SVG 导出,但需要提前安装 `selenium` 并配置浏览器环境。
Matplotlib 更像是“静态科研绘图工具”,而 Bokeh 更像是“网页交互式可视化工具”。
如果你的图表只需要放在论文或报告里,Matplotlib 已经足够;但如果你想让图表可以缩放、平移、框选、悬浮显示信息,甚至嵌入网页或做数据大屏,那么 Bokeh 就非常值得学习。
持续分享 Python 编程|数据分析|可视化干货
收藏不迷路 💫学习提升 ing,加油!

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-04 13:54:01 HTTP/2.0 GET : https://f.mffb.com.cn/a/489987.html
  2. 运行时间 : 0.129028s [ 吞吐率:7.75req/s ] 内存消耗:4,748.42kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=0fb7b057cf15e0d07721e2630c83cc33
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000732s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000804s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.005922s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000438s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000501s ]
  6. SELECT * FROM `set` [ RunTime:0.011223s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000624s ]
  8. SELECT * FROM `article` WHERE `id` = 489987 LIMIT 1 [ RunTime:0.009870s ]
  9. UPDATE `article` SET `lasttime` = 1783144441 WHERE `id` = 489987 [ RunTime:0.011236s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000241s ]
  11. SELECT * FROM `article` WHERE `id` < 489987 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000616s ]
  12. SELECT * FROM `article` WHERE `id` > 489987 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000409s ]
  13. SELECT * FROM `article` WHERE `id` < 489987 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.005797s ]
  14. SELECT * FROM `article` WHERE `id` < 489987 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.009601s ]
  15. SELECT * FROM `article` WHERE `id` < 489987 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.001370s ]
0.130623s