Convert Figma logo to code with AI

bokeh logobokeh

Interactive Data Visualization in the browser, from Python

19,538
4,202
19,538
806

Top Related Projects

16,604

The interactive graphing library for Python :sparkles: This project now includes Plotly Express!

12,776

Statistical data visualization in Python

matplotlib: plotting with Python

9,528

Declarative visualization library for Python

With Holoviews, your data visualizes itself.

Quick Overview

Bokeh is a powerful and flexible library for creating interactive visualizations in Python. It allows users to generate a wide range of plots, charts, and dashboards that can be easily embedded in web applications or exported as standalone HTML files. Bokeh emphasizes interactivity and customization, making it suitable for both data exploration and presentation.

Pros

  • Highly interactive and customizable visualizations
  • Supports both server-based and standalone HTML output
  • Extensive documentation and examples
  • Integrates well with other Python data science libraries

Cons

  • Steeper learning curve compared to some other plotting libraries
  • Can be slower to render complex visualizations with large datasets
  • Limited 3D plotting capabilities
  • Some advanced features require more in-depth knowledge of web technologies

Code Examples

  1. Creating a simple scatter plot:
from bokeh.plotting import figure, show

p = figure(title="Simple Scatter Plot")
p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=10, color="navy", alpha=0.5)
show(p)
  1. Adding interactivity with hover tooltips:
from bokeh.plotting import figure, show
from bokeh.models import HoverTool

p = figure(title="Interactive Scatter Plot")
p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=10, color="navy", alpha=0.5)

hover = HoverTool(tooltips=[("x", "@x"), ("y", "@y")])
p.add_tools(hover)

show(p)
  1. Creating a line plot with multiple series:
from bokeh.plotting import figure, show
from bokeh.palettes import Spectral11

p = figure(title="Multi-line Plot")
x = list(range(10))
for i, color in enumerate(Spectral11[0:3]):
    y = [i * j for j in x]
    p.line(x, y, line_color=color, legend_label=f"y = {i}x")

p.legend.click_policy = "hide"
show(p)

Getting Started

To get started with Bokeh, follow these steps:

  1. Install Bokeh using pip:

    pip install bokeh
    
  2. Import the necessary modules:

    from bokeh.plotting import figure, show
    
  3. Create a simple plot:

    p = figure(title="My First Bokeh Plot")
    p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5])
    show(p)
    

This will create a basic line plot and display it in your default web browser. From here, you can explore more complex visualizations and interactive features by referring to the Bokeh documentation and examples.

Competitor Comparisons

16,604

The interactive graphing library for Python :sparkles: This project now includes Plotly Express!

Pros of Plotly

  • More extensive chart types and 3D plotting capabilities
  • Easier integration with Dash for creating interactive web applications
  • Better support for scientific and statistical visualizations

Cons of Plotly

  • Steeper learning curve for beginners
  • Slower rendering for large datasets compared to Bokeh
  • Some advanced features require a paid subscription

Code Comparison

Bokeh example:

from bokeh.plotting import figure, show

p = figure(title="Simple Line Plot")
p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5])
show(p)

Plotly example:

import plotly.graph_objects as go

fig = go.Figure(data=go.Scatter(x=[1, 2, 3, 4, 5], y=[6, 7, 2, 4, 5]))
fig.show()

Both libraries offer similar basic functionality for creating plots, but Plotly's syntax is generally more concise. Bokeh provides a more "pythonic" approach, while Plotly's API is designed to be consistent across different programming languages. Plotly's code structure is often more intuitive for users familiar with other plotting libraries.

12,776

Statistical data visualization in Python

Pros of Seaborn

  • Built on top of Matplotlib, providing a higher-level interface for statistical graphics
  • Excellent for creating statistical visualizations with minimal code
  • Integrates well with pandas DataFrames for easy data manipulation

Cons of Seaborn

  • Limited interactivity compared to Bokeh's dynamic plots
  • Fewer options for customization and fine-tuning of plot elements
  • Slower rendering for large datasets compared to Bokeh

Code Comparison

Seaborn:

import seaborn as sns
import matplotlib.pyplot as plt

sns.scatterplot(x="x", y="y", data=df)
plt.show()

Bokeh:

from bokeh.plotting import figure, show

p = figure()
p.circle(df["x"], df["y"])
show(p)

Summary

Seaborn excels in creating statistical visualizations with minimal code, leveraging its integration with pandas and Matplotlib. It's ideal for quick exploratory data analysis and publication-ready plots. Bokeh, on the other hand, offers superior interactivity and performance for large datasets, making it better suited for web-based visualizations and dynamic dashboards. The choice between the two depends on the specific requirements of your project, such as the need for interactivity, dataset size, and the desired level of customization.

matplotlib: plotting with Python

Pros of Matplotlib

  • More mature and established library with extensive documentation
  • Wider range of plot types and customization options
  • Better integration with scientific computing libraries like NumPy and SciPy

Cons of Matplotlib

  • Static plots by default, requiring additional libraries for interactivity
  • Steeper learning curve for beginners
  • Less modern and aesthetically pleasing default styles

Code Comparison

Matplotlib:

import matplotlib.pyplot as plt

x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]
plt.plot(x, y)
plt.show()

Bokeh:

from bokeh.plotting import figure, show

p = figure()
p.line([1, 2, 3, 4, 5], [2, 4, 6, 8, 10])
show(p)

Both libraries offer powerful plotting capabilities, but Bokeh focuses on interactive, web-based visualizations, while Matplotlib provides a comprehensive set of tools for creating publication-quality static plots. Bokeh's syntax is often more concise and intuitive for simple plots, while Matplotlib offers more fine-grained control over plot elements. The choice between the two depends on the specific requirements of your project, such as interactivity needs, target audience, and integration with other libraries.

9,528

Declarative visualization library for Python

Pros of Altair

  • Declarative approach allows for concise and expressive code
  • Seamless integration with Pandas DataFrames
  • Strong support for interactive visualizations

Cons of Altair

  • Limited customization options compared to Bokeh
  • Steeper learning curve for users unfamiliar with grammar of graphics
  • Requires Vega and Vega-Lite dependencies

Code Comparison

Altair:

import altair as alt
import pandas as pd

data = pd.DataFrame({'x': [1, 2, 3], 'y': [4, 5, 6]})
chart = alt.Chart(data).mark_line().encode(x='x', y='y')

Bokeh:

from bokeh.plotting import figure, show

p = figure(title="Simple Line Chart")
p.line([1, 2, 3], [4, 5, 6])
show(p)

Both Altair and Bokeh are powerful visualization libraries for Python, each with its own strengths. Altair excels in creating concise, declarative visualizations, while Bokeh offers more fine-grained control over plot elements. Altair's integration with Pandas makes it particularly suitable for data exploration, whereas Bokeh's extensive customization options make it ideal for creating complex, interactive dashboards. The choice between the two often depends on the specific requirements of the project and the user's familiarity with different visualization paradigms.

With Holoviews, your data visualizes itself.

Pros of HoloViews

  • Higher-level abstraction, allowing for quicker and more concise data visualization
  • Seamless integration with multiple plotting backends (including Bokeh)
  • Powerful data selection and slicing capabilities

Cons of HoloViews

  • Steeper learning curve for users familiar with lower-level plotting libraries
  • Less fine-grained control over plot elements compared to Bokeh
  • Smaller community and ecosystem compared to Bokeh

Code Comparison

HoloViews:

import holoviews as hv
import numpy as np

xs = np.linspace(0, 10, 100)
curve = hv.Curve((xs, np.sin(xs)))
hv.render(curve)

Bokeh:

from bokeh.plotting import figure, show
import numpy as np

p = figure()
xs = np.linspace(0, 10, 100)
p.line(xs, np.sin(xs))
show(p)

Both HoloViews and Bokeh are powerful data visualization libraries, but they serve different purposes. HoloViews provides a higher-level abstraction for quick and flexible data exploration, while Bokeh offers more granular control over plot elements. HoloViews can use Bokeh as a backend, making it a versatile choice for users who want to leverage the strengths of both libraries.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Bokeh logo -- text is white in dark theme and black in light theme

Bokeh is an interactive visualization library for modern web browsers. It provides elegant, concise construction of versatile graphics and affords high-performance interactivity across large or streaming datasets. Bokeh can help anyone who wants to create interactive plots, dashboards, and data applications quickly and easily.

Package Latest package version Supported Python versions Bokeh license (BSD 3-clause)
Project Github contributors Link to NumFOCUS Link to documentation
Downloads PyPI downloads per month Conda downloads per month NPM downloads per month
Build Current Bokeh-CI github actions build status Current BokehJS-CI github actions build status Codecov coverage percentage
Community Community support on discourse.bokeh.org Bokeh-tagged questions on Stack Overflow

Consider making a donation if you enjoy using Bokeh and want to support its development.

4x9 image grid of Bokeh plots

Installation

To install Bokeh and its required dependencies using pip, enter the following command at a Bash or Windows command prompt:

pip install bokeh

To install using conda, enter the following command at a Bash or Windows command prompt:

conda install bokeh

Refer to the installation documentation for more details.

Resources

Once Bokeh is installed, check out the first steps guides.

Visit the full documentation site to view the User's Guide or checkout the Bokeh tutorial repository to learn about Bokeh in live Jupyter Notebooks.

Community support is available on the Project Discourse.

If you would like to contribute to Bokeh, please review the Contributor Guide and request an invitation to the Bokeh Dev Slack workspace.

Note: Everyone who engages in the Bokeh project's discussion forums, codebases, and issue trackers is expected to follow the Code of Conduct.

Support

Fiscal Support

The Bokeh project is grateful for individual contributions, as well as for monetary support from the organizations and companies listed below:

NumFocus Logo CZI Logo Blackstone Logo
TideLift Logo Anaconda Logo NVidia Logo Rapids Logo

If your company uses Bokeh and is able to sponsor the project, please contact info@bokeh.org

Bokeh is a Sponsored Project of NumFOCUS, a 501(c)(3) nonprofit charity in the United States. NumFOCUS provides Bokeh with fiscal, legal, and administrative support to help ensure the health and sustainability of the project. Visit numfocus.org for more information.

Donations to Bokeh are managed by NumFOCUS. For donors in the United States, your gift is tax-deductible to the extent provided by law. As with any donation, you should consult with your tax adviser about your particular tax situation.

In-kind Support

Non-monetary support can help with development, collaboration, infrastructure, security, and vulnerability management. The Bokeh project is grateful to the following companies for their donation of services:

NPM DownloadsLast 30 Days