Skip to content

Commit 0d7df3b

Browse files
committed
doc plot.py
1 parent 9523b1e commit 0d7df3b

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

examples/demo_barycenter_1D.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
pl.plot(x,A[:,i])
3838
pl.title('Distributions')
3939

40-
#%% barucenter computation
40+
#%% barycenter computation
4141

4242
# l2bary
4343
bary_l2=A.mean(1)

ot/plot.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,25 @@
99

1010

1111
def plot1D_mat(a,b,M,title=''):
12-
""" Plot matrix M with the source and target 1D distribution """
12+
""" Plot matrix M with the source and target 1D distribution
13+
14+
Creates a subplot with the source distribution a on the left and
15+
target distribution b on the tot. The matrix M is shown in between.
16+
17+
18+
Parameters
19+
----------
20+
21+
a : np.array (na,)
22+
Source distribution
23+
b : np.array (nb,)
24+
Target distribution
25+
M : np.array (na,nb)
26+
Matrix to plot
27+
28+
29+
30+
"""
1331

1432
na=M.shape[0]
1533
nb=M.shape[1]
@@ -43,7 +61,27 @@ def plot1D_mat(a,b,M,title=''):
4361

4462

4563
def plot2D_samples_mat(xs,xt,G,thr=1e-8,**kwargs):
46-
""" Plot matrix M in 2D with lines using alpha values"""
64+
""" Plot matrix M in 2D with lines using alpha values
65+
66+
Plot lines between source and target 2D samples with a color
67+
proportional to the value of the matrix G between samples.
68+
69+
70+
Parameters
71+
----------
72+
73+
xs : np.array (ns,2)
74+
Source samples positions
75+
b : np.array (nt,2)
76+
Target samples positions
77+
G : np.array (na,nb)
78+
OT matrix
79+
thr : float, optional
80+
threshold above which the line is drawn
81+
**kwargs : dict
82+
paameters given to the plot functions (default color is black if nothing given)
83+
84+
"""
4785
if ('color' not in kwargs) and ('c' not in kwargs):
4886
kwargs['color']='k'
4987
mx=G.max()

ot/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def dist(x1,x2=None,metric='sqeuclidean'):
4545
4646
Returns
4747
-------
48+
4849
M : np.array (n1,n2)
4950
distance matrix computed with given metric
5051
@@ -70,6 +71,7 @@ def dist0(n,method='lin_square'):
7071
7172
Returns
7273
-------
74+
7375
M : np.array (n1,n2)
7476
distance matrix computed with given metric
7577

0 commit comments

Comments
 (0)