Esta página se muestra en inglés. Una traducción al español está en curso.
ConfigsApr 29, 2026·3 min de lectura

Bokeh — Interactive Data Visualization for Modern Web Browsers

Bokeh is a Python library for creating interactive, publication-quality visualizations that render in the browser. It handles large datasets with ease and supports streaming, real-time updates, and server-side interactivity.

Introduction

Bokeh is a Python visualization library that produces interactive charts and dashboards rendered in modern web browsers. Unlike static plotting libraries, Bokeh generates HTML and JavaScript output, enabling pan, zoom, hover tooltips, and linked brushing without writing any frontend code.

What Bokeh Does

  • Creates interactive plots (line, bar, scatter, heatmaps, geo maps) from Python
  • Renders visualizations as standalone HTML files or embeddable components
  • Handles large datasets efficiently via server-side downsampling and WebGL rendering
  • Supports real-time streaming data updates through the Bokeh Server
  • Provides widgets (sliders, dropdowns, buttons) for building interactive dashboards

Architecture Overview

Bokeh uses a two-layer architecture. The Python layer (BokehJS model) constructs a JSON document describing glyphs, data sources, and interactions. This document is serialized and sent to BokehJS, a TypeScript library that renders the visualization using HTML5 Canvas or WebGL. The optional Bokeh Server maintains a synchronized Python-JavaScript state using WebSocket connections.

Self-Hosting & Configuration

  • Install with pip install bokeh or conda install bokeh
  • Generate standalone HTML: output_file("plot.html") then show(plot)
  • Run interactive apps with bokeh serve myapp.py for server-backed dashboards
  • Embed in Jupyter notebooks with output_notebook() for inline rendering
  • Deploy Bokeh Server behind Nginx or Apache with --allow-websocket-origin for production

Key Features

  • Browser-native rendering requires no plugins or desktop dependencies
  • Linked plots share selections and hover across multiple views automatically
  • WebGL backend handles millions of points without performance degradation
  • Bokeh Server enables Python callbacks triggered by user interactions in the browser
  • Exports to PNG and SVG for publication-ready static output

Comparison with Similar Tools

  • Matplotlib — Static plots by default; more mature for print publications but less interactive
  • Plotly — Similar interactive web plots; commercial Dash framework for dashboards
  • Altair — Declarative grammar-of-graphics approach; simpler API but fewer low-level controls
  • Seaborn — Statistical visualization built on Matplotlib; static output only
  • D3.js — Full JavaScript control; more flexible but requires writing frontend code

FAQ

Q: Can Bokeh handle millions of data points? A: Yes. Use the WebGL backend and server-side data aggregation for large datasets without browser slowdowns.

Q: How do I embed Bokeh plots in a web application? A: Use components() to get embeddable script and div tags, or use json_item() for framework integration with React or Vue.

Q: Does Bokeh work in Jupyter notebooks? A: Yes. Call output_notebook() at the start and plots render inline. Interactive widgets work via Jupyter comms.

Q: Can I create geographic/map visualizations? A: Yes. Bokeh includes tile providers (OpenStreetMap, Stamen) and supports GeoJSON for choropleth and point maps.

Sources

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados