Skip to main content

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
Tensor
required
Data values for the box plot
options
PlotOptions
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
Tensor
required
Data values for the violin plot
options
PlotOptions
Styling options
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
x
Tensor
required
Data values
bins
number | object
Number of bins (default: 10) or options object with bins property
options
PlotOptions
Styling options
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
x
Tensor
required
X-axis values
y
Tensor
required
Y-axis values
options
PlotOptions
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
data
Tensor
required
2D tensor with values to visualize
options
PlotOptions
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
x
Tensor
required
Category positions
height
Tensor
required
Bar heights
options
PlotOptions
Styling options

barh

Plot horizontal bars for categorical data.
function barh(y: Tensor, width: Tensor, options?: PlotOptions): void
y
Tensor
required
Category positions
width
Tensor
required
Bar widths
options
PlotOptions
Styling options

pie

Plot a pie chart for proportional data.
function pie(values: Tensor, labels?: readonly string[], options?: PlotOptions): void
values
Tensor
required
Slice sizes
labels
string[]
Optional labels for each slice
options
PlotOptions
Styling options
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);

Build docs developers (and LLMs) love