Plots the 3 relative joint angles (pitch, roll, yaw) from two IMUs placed on the thigh and shin, recorded during squat movements. Outputs a 3-panel time-series chart showing the primary flexion/extension angle and the two minor angles.
- Python 3.9+
- pip
1. Clone or download this project, then open a terminal in the project folder.
2. Create a virtual environment:
python3 -m venv venv3. Activate the virtual environment:
# Mac / Linux
source venv/bin/activate
# Windows
venv\Scripts\activateYou should see (venv) appear at the start of your terminal prompt.
4. Install dependencies:
pip install -r requirements.txtBasic — opens an interactive plot window:
python plot_knee_angles.py your_data.csvSave the plot to a file instead:
python plot_knee_angles.py your_data.csv output.pngThe script expects a CSV file with the following columns:
| Column | Description |
|---|---|
timestamp |
Time in milliseconds |
pitch |
Flexion/extension angle (degrees) |
roll |
Varus/valgus angle (degrees) |
yaw |
Internal/external rotation (degrees) |
seq |
Sequence number (optional) |
flex |
Flex flag (optional) |
At the top of plot_knee_angles.py you can adjust:
| Variable | Default | Description |
|---|---|---|
SMOOTHING_WINDOW |
5 |
Rolling average window in samples. Set to 1 to show raw data only. |
FIGURE_SIZE |
(14, 9) |
Width and height of the figure in inches |
PRIMARY_COLOR |
blue | Colour for pitch (flexion) panel |
SECONDARY_COLOR |
green | Colour for roll panel |
TERTIARY_COLOR |
red | Colour for yaw panel |
ALPHA_RAW |
0.25 |
Opacity of the raw data line |
When you're done:
deactivate