Skip to content

Commit 15bad5a

Browse files
committed
added an animation for the GWB visu
1 parent 833ed9f commit 15bad5a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

examples/barycenters/plot_generalised_free_support_barycenter.py renamed to examples/barycenters/plot_generalized_free_support_barycenter.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import matplotlib.pyplot as plt
2525
import matplotlib.pylab as pl
2626
import ot
27+
import matplotlib.animation as animation
2728

2829
##############################################################################
2930
# Generate and plot data
@@ -106,3 +107,29 @@
106107

107108
plt.tight_layout()
108109
plt.show()
110+
111+
##############################################
112+
# Rotation animation
113+
# --------------------------------------------
114+
115+
fig = plt.figure(figsize=(7, 7))
116+
ax = fig.add_subplot(1, 1, 1, projection="3d")
117+
118+
119+
def _init():
120+
for Xi in X_visu:
121+
ax.scatter(Xi[:, 0], Xi[:, 1], Xi[:, 2], marker='o', alpha=.6)
122+
ax.scatter(Y[:, 0], Y[:, 1], Y[:, 2], marker='o', alpha=.6)
123+
ax.view_init(elev=0, azim=0)
124+
ax.set_xticks([])
125+
ax.set_yticks([])
126+
ax.set_zticks([])
127+
return fig,
128+
129+
130+
def _update_plot(i):
131+
ax.view_init(elev=i, azim=4 * i)
132+
return fig,
133+
134+
135+
ani = animation.FuncAnimation(fig, _update_plot, init_func=_init, frames=90, interval=50, blit=True, repeat_delay=2000)

0 commit comments

Comments
 (0)