bqplot
bqplot is a 2-D visualization system for Jupyter, based on the constructs of the Grammar of Graphics. It provides interactive plotting for Jupyter notebooks, leveraging d3.js and ipywidgets. Every component of a bqplot plot is an interactive widget, allowing seamless integration with other Jupyter interactive widgets to create integrated GUIs. It offers both a flexible object model API and a concise pyplot-like API similar to Matplotlib. The library is actively maintained with frequent patch releases, and a major version (0.13.0) is in pre-release, indicating ongoing development.
Warnings
- breaking The `bqplot` 0.12.x series (including 0.12.45) is explicitly compatible with `ipywidgets < 8.0`. Upgrading `ipywidgets` to version 8.0 or higher while using `bqplot` 0.12.x will lead to broken plots and runtime errors.
- gotcha For users of JupyterLab <= 2, an additional manual installation of JupyterLab extensions is often required for `bqplot` to render correctly. Without these, plots may appear as text representations (e.g., `<bqplot.figure.Figure object at 0x...>)` instead of interactive visualizations.
- deprecated In the upcoming `bqplot` 0.13.x release, WebGL-based marks (e.g., `ScatterGL`) are being moved to a separate `bqplot-gl` package. Direct imports of these from `bqplot` will likely be deprecated or removed, requiring explicit imports from `bqplot_gl` and its installation.
Install
-
pip install bqplot -
conda install -c conda-forge bqplot
Imports
- pyplot
from bqplot import pyplot as plt
- Figure
from bqplot import Figure, LinearScale, Axis, Lines
Quickstart
import numpy as np from bqplot import pyplot as plt # Generate some data size = 100 np.random.seed(0) x_data = np.arange(size) y_data = np.cumsum(np.random.randn(size) * 100.0) # Create a figure and plot fig = plt.figure(title="My First Plot") line_plot = plt.plot(x_data, y_data) # Display the plot (in a Jupyter environment, this might be implicit or use display(fig)) # For explicit display, you'd use from IPython.display import display; display(fig) fig