# ot.plot

Functions for plotting OT matrices

Warning

Note that by default the module is not import in ot. In order to use it you need to explicitly import ot.plot

## Functions

ot.plot.plot1D_mat(a, b, M, title='')[source]

Plot matrix $$\mathbf{M}$$ with the source and target 1D distribution

Creates a subplot with the source distribution $$\mathbf{a}$$ on the left and target distribution $$\mathbf{b}$$ on the top. The matrix $$\mathbf{M}$$ is shown in between.

Parameters:
• a (ndarray, shape (na,)) – Source distribution

• b (ndarray, shape (nb,)) – Target distribution

• M (ndarray, shape (na, nb)) – Matrix to plot

### Examples using ot.plot.plot1D_mat

Optimal Transport for 1D distributions

Optimal Transport for 1D distributions

Smooth and sparse OT example

Smooth and sparse OT example

Regularized OT with generic solver

Regularized OT with generic solver

Optimal Transport solvers comparison

Optimal Transport solvers comparison

Screened optimal transport (Screenkhorn)

Screened optimal transport (Screenkhorn)

Low rank Sinkhorn

Low rank Sinkhorn

Stochastic examples

Stochastic examples

1D Unbalanced optimal transport

1D Unbalanced optimal transport
ot.plot.plot2D_samples_mat(xs, xt, G, thr=1e-08, **kwargs)[source]

Plot matrix $$\mathbf{G}$$ in 2D with lines using alpha values

Plot lines between source and target 2D samples with a color proportional to the value of the matrix $$\mathbf{G}$$ between samples.

Parameters:
• xs (ndarray, shape (ns,2)) – Source samples positions

• b (ndarray, shape (nt,2)) – Target samples positions

• G (ndarray, shape (na,nb)) – OT matrix

• thr (float, optional) – threshold above which the line is drawn

• **kwargs (dict) – parameters given to the plot functions (default color is black if nothing given)

### Examples using ot.plot.plot2D_samples_mat

Optimal Transport between 2D empirical distributions

Optimal Transport between 2D empirical distributions

Optimal Transport with different ground metrics

Optimal Transport with different ground metrics

Dual OT solvers for entropic and quadratic regularized OT with Pytorch

Dual OT solvers for entropic and quadratic regularized OT with Pytorch

OT for domain adaptation on empirical distributions

OT for domain adaptation on empirical distributions

Weak Optimal Transport VS exact Optimal Transport

Weak Optimal Transport VS exact Optimal Transport

Optimal transport with factored couplings

Optimal transport with factored couplings
ot.plot.plot1D_mat(a, b, M, title='')[source]

Plot matrix $$\mathbf{M}$$ with the source and target 1D distribution

Creates a subplot with the source distribution $$\mathbf{a}$$ on the left and target distribution $$\mathbf{b}$$ on the top. The matrix $$\mathbf{M}$$ is shown in between.

Parameters:
• a (ndarray, shape (na,)) – Source distribution

• b (ndarray, shape (nb,)) – Target distribution

• M (ndarray, shape (na, nb)) – Matrix to plot

ot.plot.plot2D_samples_mat(xs, xt, G, thr=1e-08, **kwargs)[source]

Plot matrix $$\mathbf{G}$$ in 2D with lines using alpha values

Plot lines between source and target 2D samples with a color proportional to the value of the matrix $$\mathbf{G}$$ between samples.

Parameters:
• xs (ndarray, shape (ns,2)) – Source samples positions

• b (ndarray, shape (nt,2)) – Target samples positions

• G (ndarray, shape (na,nb)) – OT matrix

• thr (float, optional) – threshold above which the line is drawn

• **kwargs (dict) – parameters given to the plot functions (default color is black if nothing given)