Last active
May 13, 2025 07:32
-
-
Save cvanelteren/2306c35c5ec6feb7663a6e003fcffd36 to your computer and use it in GitHub Desktop.
Exercise EHCO group
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"id": "23a90b48-df69-408e-a9c9-286111e92ae1", | |
"metadata": {}, | |
"source": [ | |
"# Exercise: Visualizations \n", | |
"\n", | |
"Creating graphs is part of an essential toolkit for scientists to show their work.\n", | |
"We mostly use static graphs to show what the results are of some complex analysis.\n", | |
"In this exercise, we go back to basics and expand our skills to show data that moves.\n", | |
"\n", | |
"In a sequence of steps, we learn how to animate a circle along a path." | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "47b83617-145e-4eba-99d3-4346d610df37", | |
"metadata": {}, | |
"source": [ | |
"# 🔧 STEP 1: Create a static circle centered at (0, 0)\n", | |
"\n", | |
"# TODO:\n", | |
"1. Create a figure and axis\n", | |
"2. Set aspect ratio to 'equal'\n", | |
"3. Create a circle centered at (0, 0) with a radius of 0.1\n", | |
"4. Add the circle to the axis\n", | |
"5. Set x and y limits to keep the circle in view\n", | |
"6. Display the plot" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "c804bb43-df14-42d6-bc22-3ca3643da691", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# 📦 Import necessary libraries\n", | |
"import matplotlib.pyplot as plt\n", | |
"import matplotlib.patches as patches\n", | |
"import numpy as np\n", | |
"import matplotlib.animation as animation\n", | |
"# Your code here:\n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "15ea7825-9343-407c-8c27-cbf1ae2bf127", | |
"metadata": {}, | |
"source": [ | |
"# 🎨 Step 2: Customize the Circle\n", | |
"## Goal: Change the appearance of the circle.\n", | |
"\n", | |
"Update your circle from Step 1 to have the following properties:\n", | |
"\n", | |
" facecolor = 'dodgerblue'\n", | |
"\n", | |
" edgecolor = 'black'\n", | |
"\n", | |
" alpha = 0.8" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "62f1fbb6-e1dc-4eda-9a5b-0e6f7bbe2d16", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# Your code here:" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "f4aac836-d835-4a36-b635-889fc432adc1", | |
"metadata": {}, | |
"source": [ | |
"# 🎞️ Step 3: Animate the Circle Along a Sinusoidal Path\n", | |
"\n", | |
"## Goal: Move the circle horizontally from left to right, making it follow a sine wave vertically." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "72a06c0b-319a-4b20-9f04-6a21f774fd44", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import matplotlib.animation as animation\n", | |
"# your code here" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"execution_count": null, | |
"id": "c2ae9aa5-b2bb-4861-aac8-a8c7b58131fa", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"## 🧠 Bonus Challenge\n", | |
"\n", | |
"Add a trailing dot that leaves a trace behind as the circle moves (hint: use ax.plot inside the update function)." | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3 (ipykernel)", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.12.10" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment