Module 09 Activity
Scenario
The charts are correct. Now make them reproducible and consistent across a whole deck.
What you build
A house-style function that every chart in your deck starts from, plus controlled axes, data-anchored annotations and deliberate exports.
Steps
- Rewrite every chart to use
fig, ax = plt.subplots()and work throughax. Remove any mixedplt.styling. - Set axis limits explicitly on every figure, with the floor at zero for bars.
- Move every annotation and reference line to data coordinates. Resize one figure and confirm they stay put.
- Write one house-style function that takes a title and a subtitle and returns a styled figure and axes.
- Rebuild every chart in the deck through that function.
- Export at three settings and check the result pasted into a slide, including
bbox_inches='tight'.
Evidence to hand in
- The rewritten charts with no mixed styling.
- Explicit limits on every figure.
- The resize test for annotations.
- The house-style function.
- The deck rebuilt through it.
- The export comparison.
Review checklist
- No chart mixes
plt.andax.styling. - Axis limits are set explicitly on every figure.
- Annotations survived a resize.
- Every chart in the deck comes from the one house-style function.
- Exports use bbox_inches='tight' and a resolution suited to the medium.
