Supported Libraries
marimo provides first-class support for three major plotting libraries:- Altair - Declarative visualization library based on Vega-Lite
- Plotly - Interactive graphing library
- Matplotlib - Publication-quality static plots with selection overlay
Altair Charts
Basic Usage
Accessing Selected Data
Selection Types
- Interval Selection
- Point Selection
- Legend Selection
Custom Selections
If your chart already has selection parameters, marimo respects them:Layered Charts
For layered or concatenated charts, useapply_selection():
Chart Composition
marimo’s Altair charts support composition operators:Plotly Charts
Basic Usage
Selection Data
Plotly selections provide multiple data views:Supported Chart Types
Scatter & Line
scatterscattergl(WebGL)- Line charts
- Area charts
Statistical
- Bar charts
- Histograms
- Box plots
- Violin plots
Hierarchical
- Treemap
- Sunburst
- Icicle
Specialized
- Heatmaps
- Contour plots
- Geographic maps
Configuration
Map Selections
Plotly map traces (scattergeo, scattermapbox) support selection:lat/lon coordinates:
Matplotlib Plots
Interactive Selections
marimo adds interactive selection to static matplotlib plots:Selection Types
1
Box Selection
Click and drag to select a rectangular region.
2
Lasso Selection
Hold Shift and drag to draw a freehand selection.
Using Selection Masks
Selection Objects
Thevalue attribute returns different selection types:
Debouncing
Control when selections are sent to Python:Reactive Visualizations
Combine charts with other UI elements for dashboards:min_hp changes, the chart automatically updates.
Performance Tips
For large datasets, consider these optimizations:
- Altair: Use
mark_point()withsizeencoding instead of large markers - Plotly: Use
scatterglinstead ofscatterfor 10k+ points - Matplotlib: Selections are computed in JavaScript, so they remain fast
- Data transformers: Altair supports vegafusion for server-side processing
VegaFusion
For very large Altair datasets:Theming
Charts respect marimo’s dark/light mode:- Altair: Backgrounds are automatically transparent
- Plotly: Uses the configured renderer theme
- Matplotlib: Renders with current style settings
Best Practices
- Keep charts reactive - Store chart objects in variables and reference UI values
- Use appropriate selection types - Point selection for discrete data, interval for continuous
- Handle empty selections - Check if data is selected before processing
- Combine with dataframes - Use
mo.ui.dataframe()to show selected data in tabular form - Optimize for size - Sample or aggregate data before plotting millions of points