Overview
Statistical plotting functions provide visualizations for data distributions and relationships.
Distribution Plots
boxplot
Plot a box-and-whisker diagram.
function boxplot(data: Tensor, options?: PlotOptions): void
Data values for the box plot
Styling options (color, linewidth, etc.)
Box plots display the distribution of data based on five-number summary: minimum, first quartile, median, third quartile, and maximum.
Example:
import { boxplot, randn } from 'deepbox/plot';
const data = randn([100]);
boxplot(data);
violinplot
Plot a violin diagram.
function violinplot(data: Tensor, options?: PlotOptions): void
Data values for the violin plot
Violin plots combine box plots with kernel density estimation to show the full distribution shape.
hist
Plot a histogram.
function hist(
x: Tensor,
bins?: number | (PlotOptions & { bins?: number }),
options?: PlotOptions
): void
Number of bins (default: 10) or options object with bins property
Histograms show the frequency distribution of continuous data by grouping values into bins.
Example:
import { hist, randn } from 'deepbox/plot';
const data = randn([1000]);
hist(data, 30, { color: '#2ca02c' });
Relationship Plots
scatter
Plot points to show relationships between variables.
function scatter(x: Tensor, y: Tensor, options?: PlotOptions): void
Styling options (color, size, alpha, etc.)
Scatter plots reveal correlations, clusters, and outliers in bivariate data.
Example:
import { scatter, randn, tensor } from 'deepbox/plot';
const x = randn([100]);
const y = randn([100]);
scatter(x, y, { color: '#ff7f0e', size: 3, alpha: 0.6 });
heatmap
Display data as a color-coded matrix.
function heatmap(data: Tensor, options?: PlotOptions): void
2D tensor with values to visualize
Styling options (colormap, vmin, vmax, etc.)
Heatmaps are effective for visualizing correlation matrices, confusion matrices, and dense numerical data.
Example:
import { heatmap, tensor } from 'deepbox/plot';
const correlation = tensor([
[1.0, 0.8, 0.3],
[0.8, 1.0, 0.5],
[0.3, 0.5, 1.0]
]);
heatmap(correlation, { colormap: 'coolwarm', vmin: -1, vmax: 1 });
Categorical Plots
bar
Plot vertical bars for categorical data.
function bar(x: Tensor, height: Tensor, options?: PlotOptions): void
barh
Plot horizontal bars for categorical data.
function barh(y: Tensor, width: Tensor, options?: PlotOptions): void
pie
Plot a pie chart for proportional data.
function pie(values: Tensor, labels?: readonly string[], options?: PlotOptions): void
Optional labels for each slice
Pie charts show proportions of a whole, most effective when there are 2-6 categories.
Example:
import { pie, tensor } from 'deepbox/plot';
const values = tensor([30, 25, 20, 15, 10]);
const labels = ['Category A', 'Category B', 'Category C', 'Category D', 'Category E'];
pie(values, labels);