Visualisation & export — quiz
8 questions covering this module. Charts with matplotlib and seaborn, then getting results out.
Why call savefig before show?
- It is faster
- show clears the figure, producing a blank file
- savefig needs the window
- Order does not matter
Answer: show clears the figure, producing a blank file — A classic cause of empty PNGs.
What does tight_layout fix?
- Colours
- Labels and titles being cropped
- Slow rendering
- Missing data
Answer: Labels and titles being cropped — It adjusts spacing so nothing is cut off.
Why must a bar chart y-axis start at zero?
- Convention
- Bar length encodes value, so truncation misleads
- It errors otherwise
- For colour scaling
Answer: Bar length encodes value, so truncation misleads — A truncated axis exaggerates small differences.
Which chart answers "are these two measures related"?
- Line
- Bar
- Histogram
- Scatter
Answer: Scatter — Scatter plots show relationships between two numeric measures.
Why does seaborn need long-form data?
- It is faster
- hue and col reference a column of categories
- It cannot read wide data
- To save memory
Answer: hue and col reference a column of categories — The grouping variable must be a column, not spread across columns.
Which shows median, quartiles and outliers per category?
- Histogram
- Box plot
- Scatter
- Heatmap
Answer: Box plot — Box plots compare distributions across categories.
Why pass index=False to to_csv?
- It is faster
- Otherwise the index becomes an unnamed extra column
- It is required
- To handle nulls
Answer: Otherwise the index becomes an unnamed extra column — That stray column compounds on every round trip.
For a chart going into a slide deck, prefer:
- PNG at 72 dpi
- SVG
- JPG
- PDF only
Answer: SVG — Vector output stays sharp at any size.