Lesson 34
Card 4.4: Plotting with matplotlib
New to lesson cards? See what a lesson card is.
| Format: Code workshop | Time: 30 min | Prerequisites: Card 4.3 |
Core Question
MATE wants a depth-versus-time graph as an image file, produced from your float’s data, fast, at the competition. Can your team generate it in one command?
Resource (~10 min)
The five lines that make a plot: import, read the CSV, plot x vs. y, label, save as JPG. Shown live, then dissected: which line controls what.
Activity
Using your Card 4.3 log (or the provided sample dive), produce the competition plot: depth on the y-axis (inverted, so down is down), time on x, title with team number and date, axes labeled with units, saved as a JPG, not screenshotted. Then break it on purpose: feed it a CSV with a missing line and see what happens; add the one fix that keeps it alive.
Clearing This Card
The JPG plus your script, and a 90-second live check: “Change the plot to show only the first 60 seconds” or a similar live modification.
If You Miss This Class
Sample data and the five-line skeleton are on the class page; same artifact and live check.
Why This Matters
This JPG is a scored deliverable. The team that has generated it fifty times in the studio does not sweat it on the deck. Also: this plot is how you SEE your PID tuning from Card 3.5; overshoot has a shape, and now you can look at it.
Version history
- Loading commit history…