Thanks to visit codestin.com
Credit goes to github.com

Skip to content

simple scatter animation example in quickstart #500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 46 additions & 1 deletion examples/notebooks/quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,16 @@
"fig_em[0, 0].add_animations(tick)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "774dba2e-f4c1-4c97-a427-c6f447139342",
"metadata": {},
"outputs": [],
"source": [
"fig_em.close()"
]
},
{
"cell_type": "markdown",
"id": "a202b3d0-2a0b-450a-93d4-76d0a1129d1d",
Expand Down Expand Up @@ -1410,7 +1420,7 @@
"fig_scatter = fpl.Figure()\n",
"subplot_scatter = fig_scatter[0, 0]\n",
"# use an alpha value since this will be a lot of points\n",
"scatter_graphic = subplot_scatter.add_scatter(data=cloud, sizes=3, colors=colors, alpha=0.7)\n",
"scatter_graphic = subplot_scatter.add_scatter(data=cloud, sizes=3, colors=colors, alpha=0.6)\n",
"\n",
"fig_scatter.show()"
]
Expand All @@ -1434,6 +1444,17 @@
"scatter_graphic.colors[:n_points:2] = \"r\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a5962263-8032-40ad-9981-fa0a649e2643",
"metadata": {},
"outputs": [],
"source": [
"# other half of the first cloud's points to purple\n",
"scatter_graphic.colors[1:n_points:2] = \"purple\""
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -1497,6 +1518,30 @@
"subplot_scatter.controller = \"fly\""
]
},
{
"cell_type": "markdown",
"id": "43ae13f1-d59b-4673-b0b3-669542b4c127",
"metadata": {},
"source": [
"## Animation\n",
"\n",
"Move the cloud by a small delta on every render cycle"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "50d2e96f-718c-4925-9e81-a92e81134741",
"metadata": {},
"outputs": [],
"source": [
"def update_points(subplot):\n",
" deltas = np.random.normal(size=scatter_graphic.data().shape, loc=0, scale=0.15)\n",
" scatter_graphic.data = scatter_graphic.data() + deltas\n",
"\n",
"subplot_scatter.add_animations(update_points)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down