summaryrefslogtreecommitdiff
path: root/ot/plot.py
diff options
context:
space:
mode:
authorRémi Flamary <remi.flamary@gmail.com>2016-10-24 10:28:21 +0200
committerRémi Flamary <remi.flamary@gmail.com>2016-10-24 10:28:21 +0200
commitb9ae39adae1d1a16f6bfb79e73c0d67d3157e1de (patch)
treeeee92564b9c7b02eca07b7a5a6e741245e70e5e5 /ot/plot.py
parent89999e07871f82bd1738750b5bbcd97fae9ea4b2 (diff)
update demo and add plot module
Diffstat (limited to 'ot/plot.py')
-rw-r--r--ot/plot.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/ot/plot.py b/ot/plot.py
new file mode 100644
index 0000000..b8357b1
--- /dev/null
+++ b/ot/plot.py
@@ -0,0 +1,40 @@
+
+import numpy as np
+import matplotlib.pylab as pl
+from matplotlib import gridspec
+
+
+def otplot1D(a,b,M,title=''):
+ """ Plot a with the source and target 1D distribution """
+
+ na=M.shape[0]
+ nb=M.shape[1]
+
+ gs = gridspec.GridSpec(3, 3)
+
+
+ xa=np.arange(na)
+ xb=np.arange(nb)
+
+
+ ax1=pl.subplot(gs[0,1:])
+ pl.plot(xb,b,'r',label='Target distribution')
+ pl.yticks(())
+ pl.title(title)
+
+ #pl.axis('off')
+
+ ax2=pl.subplot(gs[1:,0])
+ pl.plot(a,xa,'b',label='Source distribution')
+ pl.gca().invert_xaxis()
+ pl.gca().invert_yaxis()
+ pl.xticks(())
+ #pl.ylim((0,n))
+ #pl.axis('off')
+
+ pl.subplot(gs[1:,1:],sharex=ax1,sharey=ax2)
+ pl.imshow(M,interpolation='nearest')
+
+ pl.xlim((0,nb))
+
+