Overview
mo.ui.data_explorer() creates an interactive visualization tool that:
- Suggests appropriate chart types based on your data
- Allows drag-and-drop encoding of visual channels
- Updates visualizations in real-time
- Works with pandas, polars, and other dataframe libraries
Basic Usage
- Chart type selector (bar, line, scatter, etc.)
- Encoding channels (x, y, color, size, etc.)
- Interactive preview
Pre-configured Charts
Start with specific encodings:Available Encodings
The data explorer supports multiple visual encodings:Position
- x - X-axis position
- y - Y-axis position
- row - Facet by row
- column - Facet by column
Marks
- color - Color encoding
- size - Size of marks
- shape - Shape of points
Example: Multi-dimensional Visualization
Accessing the Chart Specification
Retrieve the chart configuration:Supported Data Types
The data explorer works with any dataframe library supported by narwhals:- Pandas
- Polars
- PyArrow
Chart Types
The data explorer automatically suggests appropriate chart types based on your data and selected encodings:- Bar charts - For categorical comparisons
- Line charts - For temporal data
- Scatter plots - For correlations
- Histograms - For distributions
- Box plots - For statistical summaries
- Heatmaps - For matrix data
Interactive Features
Reactive Updates
The data explorer is reactive - when the input dataframe changes, the visualization automatically updates:Combining with Other UI Elements
Create dashboards by combining the data explorer with other components:Performance Considerations
For large datasets (100k+ rows), the data explorer uses sampling to maintain interactivity.
- Data is automatically sampled for preview
- Full dataset is used for aggregations
- Consider pre-aggregating very large datasets
Under the Hood
The data explorer uses:- Vega-Lite for declarative visualizations
- Altair (via marimo’s chart transformer) for efficient rendering
- CSV data transformation for browser compatibility
Example: Sales Dashboard
- Switch to different chart types
- Add faceting by region
- Change aggregation methods
- Explore temporal patterns
Comparison with Other Tools
Use the data explorer for quick exploration, then switch to
mo.ui.altair_chart() or mo.ui.plotly() for production visualizations.
Tips
Limitations
- Chart customization is limited compared to programmatic approaches
- Complex visualizations may require
mo.ui.altair_chart()ormo.ui.plotly() - No direct access to underlying Vega-Lite specification for modification