Showing Groups in One Scatterplot
A scatterplot can show the relationship between two quantitative variables, but a third variable may also matter: group membership. For example, a scatterplot of study time and quiz score might use a different symbol for each course section. This lets a reader see the observations in one shared plotting area while distinguishing which section each observation belongs to.
Color and point shape are visual channels for encoding categories. Used carefully, they make group membership easier to see without changing the horizontal or vertical positions of the observations. But a colored symbol is not a new measurement, and the appearance of separate clusters is not proof of a group effect. The plot is a way to display the recorded data; any interpretation must remain tied to the variables and context.
Suppose each data row contains a quantitative predictor, a quantitative response, and a category. Choose one consistent color and/or shape for each category, then use that same mapping for every observation in the plot. The horizontal and vertical positions still represent the predictor and response. The category changes the mark's appearance, not its coordinates.
Before making the plot, check that each row represents one observation, that the two numeric variables are correctly identified, and that the group variable has clear category labels. Use the same axis scales and coordinate system for all groups. If categories are missing or mislabeled, the visual coding cannot repair that data problem.
Choosing and Explaining the Visual Mapping
Color can make several groups easy to distinguish at a glance, while shape can continue to distinguish them when colors are hard to see or the plot is printed in grayscale. Applying both channels to the same category is called redundant encoding: for example, every North-group observation is both blue and a circle. This provides two visual cues for one group label, rather than representing two separate variables.
Redundant encoding can be useful, but it is not automatically clearer. A plot with many colors and many shapes can burden the reader with too many combinations to remember. Choose colors with strong visual contrast, avoid relying only on subtle differences in shade, and use shapes that are distinguishable at the plotted size. If color is used, ensure the legend displays the same colors and symbols as the points. If the plot may be viewed in grayscale, test whether the shapes still distinguish the groups.
The legend should name the category variable and reproduce the actual symbol used for each category. Its labels should be meaningful in context, such as “Section A” and “Section B,” rather than unexplained codes such as 1 and 2. Arrange entries in a sensible order, and place the legend where it does not cover important observations. A reader should be able to match a point to a group without guessing.
Worked Example: Encoding Three Course Sections
Hypothetical data: An instructor records study hours and quiz scores for six students, two from each of three course sections. The data are shown below.
| Section | Study hours | Quiz score (points out of 20) |
|---|---|---|
| A | 2 | 11 |
| A | 4 | 14 |
| B | 3 | 12 |
| B | 5 | 16 |
| C | 2 | 9 |
| C | 5 | 13 |
Put study hours on the horizontal axis and quiz score on the vertical axis. Then assign a distinct symbol to each section: for example, blue circles for A, orange squares for B, and green triangles for C. Every row becomes one point at its recorded coordinates. Thus the first row is a circle at (2, 11), and the last row is a triangle at (5, 13).
The mapping is consistent because both A observations are circles, both B observations are squares, and both C observations are triangles. The legend should show each symbol alongside its section label. A reader can then compare the point locations while keeping track of section membership. The plot does not by itself establish that section membership caused any difference in scores.
Why the Legend and Mapping Matter
A symbol has no universal group meaning: a triangle does not inherently mean “Section C.” Its meaning comes from the mapping stated in the legend. If the mapping changes partway through a plot, or if the legend is absent, a reader may assign points to the wrong groups. The basic check is to select any row, locate its plotted coordinates, and verify that its symbol agrees with the category assigned in the legend.
When both color and shape are used, make their mappings agree. If Section A is blue and circular, every Section A point should be blue and circular. Do not use blue to mean one group and circles to mean a different group unless the legend clearly explains that the channels encode separate variables. For the goal of distinguishing one categorical grouping, a consistent combined symbol is usually simpler.
A single plot puts the groups on common axes, which can help reveal where their observations overlap and where they differ. The earlier material on faceted scatterplots considers a different display choice: separate panels for groups. Here, the focus is on one plotting area. Whether one plot remains readable depends on how many groups there are, how distinct their symbols are, and how much their points overlap.
Worked Example: Checking Overlap at Shared Coordinates
Hypothetical data: Six observations belong to Group A and six to Group B. In each group, two observations have the same predictor and response values, (4, 8). The other observations have distinct coordinates that do not coincide with one another or with (4, 8).
Suppose circles represent Group A and squares represent Group B, with color also used consistently for each group. At (4, 8), the two Group A records share a coordinate, as do the two Group B records. The number of records from each group at that location is 2, out of 6 in that group. The fraction is
So about 33.3% of each group's observations are at that shared coordinate. Across both groups, four records occupy (4, 8), even though the plot may show only one circle and one square there. The different group symbols show that both groups are represented, but they do not reveal the repeated records within either group.
This is a direct warning that symbol coding cannot always show how many observations occupy a location. A viewer might notice the coincident marks and still underestimate how many records they represent. Check for repeated coordinates in the data, and consider the earlier material on reducing overplotting with jitter and transparency when appropriate. If the plot remains crowded, report the limitation rather than implying that every record is visually distinct.
When More Visual Coding Does Not Help
Adding more colors or shapes cannot solve every display problem. If there are many categories, symbols may become difficult to distinguish and the legend may dominate the plot. If many observations share or nearly share coordinates, marks can obscure one another even when the group coding is correct. In either case, a single scatterplot may not support reliable visual comparisons.
Consider the difference between category confusion and point overlap. Category confusion occurs when a reader cannot tell what a symbol means, often because the legend is unclear or the mappings are too similar. Point overlap occurs when two or more observations occupy the same or nearby positions, so their marks partly or fully cover each other. A clearer legend helps with the first problem; it does not necessarily solve the second.
A practical review is to trace a few records from the data table to the plot: confirm their coordinates, category, and displayed symbol. Then inspect the legend and check whether the categories remain distinguishable at the size at which the plot will be viewed. Finally, look for crowded regions and coincident observations. If comparison is still difficult, the honest conclusion is that the display has limits—not that the groups have no differences or that any visible pattern must be real.
Worked Example: Choosing a Grayscale-Safe Mapping
Hypothetical data: A student plots 10 measurements of temperature and cooling time, with five observations from each of two container types: metal and glass. The plot may be printed in grayscale. The student first considers assigning dark blue to metal and light blue to glass, but the shades appear similar when reduced to the intended print size.
Because color alone may not reliably distinguish the two categories in this setting, the student uses circles for metal and triangles for glass. The legend shows a circle labelled “Metal” and a triangle labelled “Glass.” If color is also retained, it is an additional cue, not the only one.
There are five observations in each category, so the display should contain five circles and five triangles, one mark per recorded row. The count is \(5+5=10\), matching the 10 rows. This check confirms that no observations were accidentally omitted during plotting; it does not guarantee that all 10 marks will appear separately if some coordinates overlap.
The revised design gives the reader a category cue that does not depend on distinguishing two similar shades. If circles and triangles are still too small or crowded to tell apart, the student should change the display conditions or use another way of presenting the groups rather than claiming the plot is clear.
Common Mistakes and a Final Check
- Changing the meaning of a symbol. If a shape represents a category, use it consistently for every observation in that category.
- Assuming the symbol explains itself. Include a clear legend with category labels and matching visual keys.
- Using color as the only cue when visibility is uncertain. Add distinguishable shapes or choose a display that remains interpretable without color.
- Assuming one visible mark equals one observation. Repeated coordinates can place several records under the same symbol.
- Reading a visual difference as a cause. A grouped scatterplot displays observed values; it does not establish that group membership caused them.
- Adding visual distinctions without checking readability. More colors and shapes can make a plot harder, not easier, to decode.
Check Your Understanding
Answer these questions using the definitions and examples above.
- A scatterplot uses study hours on the horizontal axis, quiz score on the vertical axis, and course section as a category. What do the point coordinates represent, and what does the point shape represent?
- Why should a legend show the same colors and shapes that appear in the plotted observations?
- Two observations in each of two groups share the same coordinates. Explain why the plot may show fewer distinct marks than there are records at that location.
- A plot will be printed in grayscale, and its two group colors look almost identical. Name one change that could make the categories easier to distinguish.
- What is the difference between an unclear category legend and overlapping points?
- Why does a visible difference between groups in a grouped scatterplot not, by itself, demonstrate causation?