ETF5922 Chap.4 Grammar of Graphics and Basic Plots
Grammar of Graphics and Basic Plots
Mappings create the visual sentence
The grammar of graphics separates data, aesthetic mappings and geometric layers. Putting colour inside aes maps a variable, while setting colour in a geom gives every mark the same appearance.
Tuning changes visible structure
Histogram bin width and density bandwidth change how local structure appears.
Rugs preserve observation locations and boxplots compress centre, spread and potential outliers.
Cross-check a distribution
Bin width changes which observations are pooled into histogram bars, while bandwidth changes the smoothing of a density estimate.
Both can reveal or conceal structure, so conclusions should survive several defensible settings.
Cross-check a distribution in context
Basic plots are alternative measurement instruments rather than interchangeable decorations.
A bar chart supports category magnitude, a histogram pools a continuous variable into intervals, a density estimate smooths observations, a rug preserves individual locations and a boxplot compresses distributional landmarks. The grammar of graphics exposes the decisions connecting data, mappings, marks, transformations and scales. Changing bin width or bandwidth performs a sensitivity analysis on visible structure.
A careful reader distinguishes features stable in the raw observations from peaks or gaps created by tuning, then selects a display combination matched to the substantive comparison.
What this chapter covers
- 01
The grammar of graphics separates data, aesthetic mappings and geometric layers.
- 02
Putting colour inside aes maps a variable, while setting colour in a geom gives every mark the same appearance.
- 03
Histogram bin width and density bandwidth change how local structure appears.
- 04
Rugs preserve observation locations and boxplots compress centre, spread and potential outliers.
- 05
Use dataset and aesthetic to frame the reader's task
- 06
Check mapping against geom before styling
- 07
Explain how scale changes the visible comparison
- 08
Audit facet without removing necessary context
Test a distribution against tuning choices
- 3List the raw observations before selecting a distribution display.
- 2Compute the total and mean, noting the high pair that shifts the centre.
- 1Pair smoothing with a rug or boxplot so individual evidence remains recoverable.
- 2Compare at least two tuning choices before describing modes or outliers.
Key terms
- Aesthetic mapping
- A variable-to-channel connection declared inside the plotting grammar, such as value to vertical position.
- Geometric layer
- A mark type used to draw observations or summaries, including points, bars, lines and boxplots.
- Bin width
- The interval used to pool observations into each histogram rectangle.
- Bandwidth
- The smoothing parameter controlling how local or broad a density estimate appears.
Grammar of Graphics and Basic Plots FAQ
How do bin width and bandwidth alter a distribution?
Bin width changes which observations are pooled into histogram bars, while bandwidth changes the smoothing of a density estimate. Both can reveal or conceal structure, so conclusions should survive several defensible settings.
Which display should accompany a density curve?
A rug or another raw-observation layer helps readers see the evidence that smoothing compresses. Histograms and boxplots provide complementary summaries. The best companion depends on the question, but the underlying observations should remain recoverable when bandwidth choices could alter apparent peaks.
What makes a bin width defensible?
A defensible width reveals relevant structure without manufacturing gaps or merging substantively different values, and the conclusion remains similar under nearby reasonable widths. Report the choice when it materially affects interpretation and compare with raw marks rather than treating the default as neutral.
Why compare a histogram with a rug?
The histogram shows pooled counts while the rug preserves exact observation locations. Reading them together reveals whether a gap or cluster comes from the data or from bin boundaries. Nearby bin widths should be tried when the conclusion depends on a particular partition, and any unstable feature should be reported cautiously.
Exam move
Draw the same numeric vector as a rug, histogram, density estimate and boxplot. Recalculate the mean, vary bin width and bandwidth, and note which apparent features persist. For each display, name the perceptual task it supports and one feature it suppresses. A final paragraph should distinguish a robust distributional observation from a tuning-sensitive impression.
Working through Grammar of Graphics and Basic Plots in ETF5922? Sia is AskSia’s AI Computer Science tutor — ask any ETF5922 Grammar of Graphics and Basic Plots question and get a clear, step-by-step explanation grounded in how ETF5922 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.