|
1422 | 1422 | "# use an alpha value since this will be a lot of points\n", |
1423 | 1423 | "scatter_graphic = subplot_scatter.add_scatter(data=cloud, sizes=3, colors=colors, alpha=0.6)\n", |
1424 | 1424 | "\n", |
1425 | | - "fig_scatter.show()" |
| 1425 | + "fig_scatter.show(sidecar=True)" |
1426 | 1426 | ] |
1427 | 1427 | }, |
1428 | 1428 | { |
|
1536 | 1536 | "outputs": [], |
1537 | 1537 | "source": [ |
1538 | 1538 | "def update_points(subplot):\n", |
| 1539 | + " # move every point by a small amount\n", |
1539 | 1540 | " deltas = np.random.normal(size=scatter_graphic.data().shape, loc=0, scale=0.15)\n", |
1540 | | - " scatter_graphic.data = scatter_graphic.data() + deltas\n", |
| 1541 | + " scatter_graphic.data = scatter_graphic.data() + deltas \n", |
1541 | 1542 | "\n", |
1542 | 1543 | "subplot_scatter.add_animations(update_points)" |
1543 | 1544 | ] |
1544 | 1545 | }, |
| 1546 | + { |
| 1547 | + "cell_type": "markdown", |
| 1548 | + "id": "1592c6cd-d10a-4bda-ac4b-e06d428ffa1d", |
| 1549 | + "metadata": {}, |
| 1550 | + "source": [ |
| 1551 | + "Another animation function to cycle the colors of one of the clouds" |
| 1552 | + ] |
| 1553 | + }, |
| 1554 | + { |
| 1555 | + "cell_type": "code", |
| 1556 | + "execution_count": null, |
| 1557 | + "id": "fb0394a3-47d9-4620-a754-d04d5f313cc7", |
| 1558 | + "metadata": {}, |
| 1559 | + "outputs": [], |
| 1560 | + "source": [ |
| 1561 | + "i = 0.05\n", |
| 1562 | + "def cycle_colors(subplot):\n", |
| 1563 | + " global i\n", |
| 1564 | + " # cycle the red values\n", |
| 1565 | + " scatter_graphic.colors[n_points * 2:, 0] = np.abs(np.sin(i))\n", |
| 1566 | + " scatter_graphic.colors[n_points * 2:, 1] = np.abs(np.sin(i + (np.pi / 4)))\n", |
| 1567 | + " scatter_graphic.colors[n_points * 2:, 2] = np.abs(np.cos(i))\n", |
| 1568 | + " i += 0.05\n", |
| 1569 | + "\n", |
| 1570 | + "subplot_scatter.add_animations(cycle_colors)" |
| 1571 | + ] |
| 1572 | + }, |
1545 | 1573 | { |
1546 | 1574 | "cell_type": "code", |
1547 | 1575 | "execution_count": null, |
|
2020 | 2048 | "name": "python", |
2021 | 2049 | "nbconvert_exporter": "python", |
2022 | 2050 | "pygments_lexer": "ipython3", |
2023 | | - "version": "3.11.3" |
| 2051 | + "version": "3.11.2" |
2024 | 2052 | } |
2025 | 2053 | }, |
2026 | 2054 | "nbformat": 4, |
|
0 commit comments