| 1344 | |
| 1345 | |
| 1346 | def render_animation(args): |
| 1347 | from matplotlib import pyplot as plt |
| 1348 | from mpl_toolkits.mplot3d import Axes3D |
| 1349 | plt.switch_backend("agg") |
| 1350 | |
| 1351 | coordinates, Y, degree, figure_size, scale, elevation = args |
| 1352 | classes = sorted(np.unique(Y)) |
| 1353 | |
| 1354 | fig = plt.figure(figsize=(figure_size, figure_size)) |
| 1355 | ax = fig.gca(projection="3d") |
| 1356 | for cls in classes: |
| 1357 | indexes, = np.where(Y == cls) |
| 1358 | ax.scatter(*coordinates[indexes].T, s=scale) |
| 1359 | ax.view_init(elev=elevation, azim=degree) |
| 1360 | ax.set_xticks([]) |
| 1361 | ax.set_yticks([]) |
| 1362 | ax.set_zticks([]) |
| 1363 | if len(classes) > 1: |
| 1364 | ax.legend(classes, markerscale=6) |
| 1365 | fig.canvas.draw() |
| 1366 | frame = np.asarray(fig.canvas.renderer._renderer) |
| 1367 | |
| 1368 | return frame |
| 1369 | |
| 1370 | |
| 1371 | class Application(object): |