diff options
author | Alexandre Gramfort <alexandre.gramfort@m4x.org> | 2017-07-12 22:51:17 +0200 |
---|---|---|
committer | Alexandre Gramfort <alexandre.gramfort@m4x.org> | 2017-07-20 14:05:12 +0200 |
commit | 25ef32ff892fba105a4a116a804b1e4f08ae57cd (patch) | |
tree | cc58adb198141841e2e5dab9c4f33253556f8f65 /examples/plot_OT_2D_samples.py | |
parent | d6091dae858a82f69e6843859f164269fa338c6b (diff) |
more
Diffstat (limited to 'examples/plot_OT_2D_samples.py')
-rw-r--r-- | examples/plot_OT_2D_samples.py | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/examples/plot_OT_2D_samples.py b/examples/plot_OT_2D_samples.py index 3a93591..75ed7db 100644 --- a/examples/plot_OT_2D_samples.py +++ b/examples/plot_OT_2D_samples.py @@ -8,7 +8,7 @@ """ import numpy as np -import matplotlib.pylab as plt +import matplotlib.pylab as pl import ot #%% parameters and data generation @@ -32,31 +32,31 @@ M /= M.max() #%% plot samples -plt.figure(1) -plt.plot(xs[:, 0], xs[:, 1], '+b', label='Source samples') -plt.plot(xt[:, 0], xt[:, 1], 'xr', label='Target samples') -plt.legend(loc=0) -plt.title('Source and target distributions') +pl.figure(1) +pl.plot(xs[:, 0], xs[:, 1], '+b', label='Source samples') +pl.plot(xt[:, 0], xt[:, 1], 'xr', label='Target samples') +pl.legend(loc=0) +pl.title('Source and target distributions') -plt.figure(2) -plt.imshow(M, interpolation='nearest') -plt.title('Cost matrix M') +pl.figure(2) +pl.imshow(M, interpolation='nearest') +pl.title('Cost matrix M') #%% EMD G0 = ot.emd(a, b, M) -plt.figure(3) -plt.imshow(G0, interpolation='nearest') -plt.title('OT matrix G0') +pl.figure(3) +pl.imshow(G0, interpolation='nearest') +pl.title('OT matrix G0') -plt.figure(4) +pl.figure(4) ot.plot.plot2D_samples_mat(xs, xt, G0, c=[.5, .5, 1]) -plt.plot(xs[:, 0], xs[:, 1], '+b', label='Source samples') -plt.plot(xt[:, 0], xt[:, 1], 'xr', label='Target samples') -plt.legend(loc=0) -plt.title('OT matrix with samples') +pl.plot(xs[:, 0], xs[:, 1], '+b', label='Source samples') +pl.plot(xt[:, 0], xt[:, 1], 'xr', label='Target samples') +pl.legend(loc=0) +pl.title('OT matrix with samples') #%% sinkhorn @@ -66,15 +66,15 @@ lambd = 5e-4 Gs = ot.sinkhorn(a, b, M, lambd) -plt.figure(5) -plt.imshow(Gs, interpolation='nearest') -plt.title('OT matrix sinkhorn') +pl.figure(5) +pl.imshow(Gs, interpolation='nearest') +pl.title('OT matrix sinkhorn') -plt.figure(6) +pl.figure(6) ot.plot.plot2D_samples_mat(xs, xt, Gs, color=[.5, .5, 1]) -plt.plot(xs[:, 0], xs[:, 1], '+b', label='Source samples') -plt.plot(xt[:, 0], xt[:, 1], 'xr', label='Target samples') -plt.legend(loc=0) -plt.title('OT matrix Sinkhorn with samples') +pl.plot(xs[:, 0], xs[:, 1], '+b', label='Source samples') +pl.plot(xt[:, 0], xt[:, 1], 'xr', label='Target samples') +pl.legend(loc=0) +pl.title('OT matrix Sinkhorn with samples') -plt.show() +pl.show() |