Skip to content

cycle colors in scatter example #501

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
34 changes: 31 additions & 3 deletions examples/notebooks/quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@
"# 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.6)\n",
"\n",
"fig_scatter.show()"
"fig_scatter.show(sidecar=True)"
]
},
{
Expand Down Expand Up @@ -1536,12 +1536,40 @@
"outputs": [],
"source": [
"def update_points(subplot):\n",
" # move every point by a small amount\n",
" deltas = np.random.normal(size=scatter_graphic.data().shape, loc=0, scale=0.15)\n",
" scatter_graphic.data = scatter_graphic.data() + deltas\n",
" scatter_graphic.data = scatter_graphic.data() + deltas \n",
"\n",
"subplot_scatter.add_animations(update_points)"
]
},
{
"cell_type": "markdown",
"id": "1592c6cd-d10a-4bda-ac4b-e06d428ffa1d",
"metadata": {},
"source": [
"Another animation function to cycle the colors of one of the clouds"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fb0394a3-47d9-4620-a754-d04d5f313cc7",
"metadata": {},
"outputs": [],
"source": [
"i = 0.05\n",
"def cycle_colors(subplot):\n",
" global i\n",
" # cycle the red values\n",
" scatter_graphic.colors[n_points * 2:, 0] = np.abs(np.sin(i))\n",
" scatter_graphic.colors[n_points * 2:, 1] = np.abs(np.sin(i + (np.pi / 4)))\n",
" scatter_graphic.colors[n_points * 2:, 2] = np.abs(np.cos(i))\n",
" i += 0.05\n",
"\n",
"subplot_scatter.add_animations(cycle_colors)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -2020,7 +2048,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.11.2"
}
},
"nbformat": 4,
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy