Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
gpui-px
High-level Plotly Express-style charting API for GPUI. Create beautiful, interactive charts in just a few lines of Rust.
Built on top of gpui-d3rs primitives.
Features
- 6 chart types: Scatter, Line, Bar, Heatmap, Contour, Isoline
- Fluent builder API: Chain methods for easy configuration
- Color scales: Viridis, Plasma, Inferno, Magma, Heat, Coolwarm, Greys, or custom
- Logarithmic scales: Both axes support log scaling for multi-magnitude data
- Validation: Comprehensive error handling for invalid data
Installation
[]
= "0.1"
Quick Start
use ;
// Create a scatter plot in 3 lines
let chart = scatter
.title
.build?;
Chart Types
Scatter
Displays individual data points with x,y coordinates. Ideal for exploring correlations, identifying clusters, and spotting outliers.
use scatter;
let x = vec!;
let y = vec!;
let chart = scatter
.title
.color // Plotly blue
.point_radius
.opacity
.size
.build?;
Line
Connects data points to show trends over continuous domains. Perfect for time series, measurements, and sequential data.
use ;
let time: = .map.collect;
let signal: = time.iter.map.collect;
let chart = line
.title
.color // Orange
.stroke_width
.curve
.show_points
.size
.build?;
Bar
Compares values across discrete categories. Great for rankings, counts, and distributions.
use bar;
let categories = vec!;
let values = vec!;
let chart = bar
.title
.color // Green
.bar_gap
.border_radius
.size
.build?;
Heatmap
Visualizes 2D scalar fields using color. Perfect for spectrograms, correlation matrices, and geographic data.
use ;
// 10x10 grid of values
let z: = .map.collect;
let chart = heatmap
.title
.color_scale
.size
.build?;
Contour
Shows filled bands between threshold values. Great for topographic visualizations and density estimation.
use ;
// Generate a 2D Gaussian
let size = 50;
let z: = .map.collect;
let chart = contour
.title
.thresholds
.color_scale
.size
.build?;
Isoline
Draws unfilled contour lines at specific levels. Useful for elevation maps, pressure fields, and level curves.
use isoline;
// Same data as contour example
let z: = /* ... */;
let chart = isoline
.title
.levels
.color
.stroke_width
.size
.build?;
Logarithmic Scales
All chart types support logarithmic axis scaling for data spanning multiple orders of magnitude.
use ;
// Log-log scatter plot (power-law relationships)
let chart = scatter
.x_scale
.y_scale
.build?;
// Frequency response (audio engineering)
let freq: = .map.collect;
let chart = line
.x_scale
.title
.build?;
// Bar chart with log Y-axis
let chart = bar
.y_scale
.build?;
Note: Logarithmic scales require all values to be positive. Zero or negative values will cause validation errors.
Color Scales
For 2D charts (heatmap, contour), use the ColorScale enum:
| Scale | Description |
|---|---|
Viridis |
Perceptually uniform, colorblind-friendly (default) |
Plasma |
Perceptually uniform, purple-orange-yellow |
Inferno |
Perceptually uniform, black-purple-orange-yellow |
Magma |
Perceptually uniform, black-purple-orange-white |
Heat |
Diverging, blue-white-red |
Coolwarm |
Diverging, cool blue to warm red |
Greys |
Sequential grayscale |
Custom color scales:
use ColorScale;
use D3Color;
let custom = custom;
Color Format
For 1D charts (scatter, line, bar, isoline), colors use 24-bit RGB hex values:
.color // Plotly blue
.color // Plotly orange
.color // Plotly green
.color // Plotly red
.color // Plotly purple
Showcase
Run the interactive showcase to see all chart types:

API Overview
All chart builders share a common pattern:
chart_type // Create builder with required data
.title // Optional title
.color // Color (1D charts)
.color_scale // Color scale (2D charts)
.size // Chart dimensions
.build? // Validate and build
Scatter
| Method | Description |
|---|---|
title(s) |
Chart title |
color(hex) |
Point color |
point_radius(r) |
Point size in pixels |
opacity(o) |
Point opacity (0.0-1.0) |
x_scale(type) |
X-axis scale (Linear/Log) |
y_scale(type) |
Y-axis scale (Linear/Log) |
size(w, h) |
Chart dimensions |
Line
| Method | Description |
|---|---|
title(s) |
Chart title |
color(hex) |
Line color |
stroke_width(w) |
Line width in pixels |
opacity(o) |
Line opacity (0.0-1.0) |
curve(type) |
Interpolation (Linear, etc.) |
show_points(b) |
Show data point markers |
x_scale(type) |
X-axis scale (Linear/Log) |
y_scale(type) |
Y-axis scale (Linear/Log) |
size(w, h) |
Chart dimensions |
Bar
| Method | Description |
|---|---|
title(s) |
Chart title |
color(hex) |
Bar fill color |
opacity(o) |
Bar opacity (0.0-1.0) |
bar_gap(g) |
Gap between bars in pixels |
border_radius(r) |
Corner radius |
y_scale(type) |
Y-axis scale (Linear/Log) |
size(w, h) |
Chart dimensions |
Heatmap
| Method | Description |
|---|---|
title(s) |
Chart title |
x(values) |
Custom x-axis values |
y(values) |
Custom y-axis values |
color_scale(scale) |
Color mapping |
opacity(o) |
Fill opacity (0.0-1.0) |
x_scale(type) |
X-axis scale (Linear/Log) |
y_scale(type) |
Y-axis scale (Linear/Log) |
size(w, h) |
Chart dimensions |
Contour
| Method | Description |
|---|---|
title(s) |
Chart title |
x(values) |
Custom x-axis values |
y(values) |
Custom y-axis values |
thresholds(vec) |
Threshold values for bands |
color_scale(scale) |
Color mapping |
opacity(o) |
Fill opacity (0.0-1.0) |
x_scale(type) |
X-axis scale (Linear/Log) |
y_scale(type) |
Y-axis scale (Linear/Log) |
size(w, h) |
Chart dimensions |
Isoline
| Method | Description |
|---|---|
title(s) |
Chart title |
x(values) |
Custom x-axis values |
y(values) |
Custom y-axis values |
levels(vec) |
Level values for lines |
color(hex) |
Line color |
stroke_width(w) |
Line width in pixels |
opacity(o) |
Line opacity (0.0-1.0) |
x_scale(type) |
X-axis scale (Linear/Log) |
y_scale(type) |
Y-axis scale (Linear/Log) |
size(w, h) |
Chart dimensions |
Coordinate System
All charts use standard mathematical coordinates:
- Y-axis: 0 at bottom, increases upward
- X-axis: 0 at left, increases rightward
Error Handling
The build() method returns Result<impl IntoElement, ChartError>:
use ChartError;
match scatter.build