Keep the measured axis exact, treat sideways displacement as layout, and disclose how many marks are present.
Beeswarm plots: show individual values without inventing spread
A dot is an observation
A beeswarm places individual observations along a measured axis and moves marks sideways only enough to reduce overlap. The lateral coordinate is not a second measured variable. State that in the axis caption, because a wide swarm can otherwise be mistaken for more variation. If the mark count exceeds the display's collision capacity, use a declared sample or a distribution summary instead of silently dropping points. Overplotting and sampling bias determine whether the displayed dots still represent the underlying population. Report the raw count and the displayed count for every group.
Preserve ties and identity
Repeated equal measurements should remain repeated observations. A deterministic layout lets an analyst compare revisions without random movement that looks like new data. Stable IDs matter when a reader selects or exports a point. If several rows share the same subject and timestamp, decide whether they are repeated measurements or duplicates before drawing. The plot cannot make that data decision. The export manifest should preserve observation ID, group, measured value, sampling rule and layout version. A text alternative can list the median, range, count and number of tied values.
Collision radius is a visual parameter
A beeswarm solver needs marker diameter in display pixels as well as the scale that maps values to pixels. Zooming, resizing or switching to mobile changes collision geometry. Thus an offset computed for one viewport cannot safely be reused for another. Cap the lateral spread only if the chart explicitly allows overlap after that cap; hiding dots is not acceptable. Accessible mark encodings need a visible outline or shape difference when groups share a panel. Test the chart at the narrowest intended width.
Compare with a distribution summary
The swarm is good for a few hundred visible records, particularly when outliers and ties are the story. At larger scale it becomes slow to lay out and hard to read. A box, violin or ECDF can summarize shape, while a small sample of dots reveals examples without pretending to be complete. Box and violin plots have their own bandwidth and whisker decisions; they are not interchangeable with raw observations. If groups have unequal sample sizes, annotate counts next to labels so width is not mistaken for prevalence.
Worked contract
from hashlib import sha256
from math import isfinite
def stable_strip_positions(records: list[tuple[str, str, float]],
spread: float = 0.38) -> list[tuple[str, str, float, float]]:
if not 0 <= spread <= 0.5:
raise ValueError("spread must fit inside one category")
identifiers = [record_id for record_id, _, _ in records]
if len(identifiers) != len(set(identifiers)) or any(not key for key in identifiers):
raise ValueError("observation IDs must be unique and nonempty")
if any(not group or not isfinite(value) for _, group, value in records):
raise ValueError("group and measured value must be valid")
placed = []
for record_id, group, value in records:
digest = sha256(record_id.encode("utf-8")).digest()
fraction = int.from_bytes(digest[:8], "big") / (2**64 - 1)
placed.append((record_id, group, value, (2 * fraction - 1) * spread))
return placed
service_times = [("ticket-47", "priority", 81.0),
("ticket-59", "priority", 81.0),
("ticket-83", "standard", 97.0)]
positions = stable_strip_positions(service_times)
assert len(positions) == 3 and positions[0][2] == positions[1][2]
assert positions == stable_strip_positions(service_times)Performance and operating cost
Preparing N stable strip positions takes O(N) expected time and O(N) output space. This code produces reproducible jitter; it is not a collision-solving beeswarm. A true beeswarm needs screen-space marker geometry and may require O(N squared) comparisons in a simple placement algorithm. Do not label the jittered result collision-free. Preserve exact measured values and IDs in the export, and recalculate visual offsets when the display scale changes.
Common Mistakes
- Reading sideways jitter as a measured quantity.
- Suppressing overlapped observations without recording the omitted count.
- Reseeding random positions on every redraw, making stable records appear to move.
- Calling deterministic jitter a collision-free beeswarm without checking marker radius.
Validation drill
Draw 81 support-ticket response times across three queues. Keep equal values as separate dots, show each queue's count and compare a narrow mobile layout with a distribution summary.
Read next
- Dense scatterplots: reveal overlap without hiding rare observations
- Box and violin charts: compare groups without inventing density
- Accessible charts: encode meaning without relying on color alone
- Chart exports: carry the data, filters and render contract together
