| cleveland_shape_pal | R Documentation |
Shape palettes for overlapping and non-overlapping points.
cleveland_shape_pal(overlap = TRUE, unicode = FALSE)
overlap |
|
unicode |
If |
A palette function. It takes the number of shapes n and returns an integer vector of n
shape (pch) codes, and can be used as the palette argument of
discrete_scale().
In the Elements of Graphing Data, W.S. Cleveland suggests two shape palettes for scatter plots: one for overlapping data and another for non-overlapping data. The symbols for overlapping data rely on pattern discrimination, while the symbols for non-overlapping data vary the amount of fill.
Following Tremmel (1995), the circle with a vertical line is replaced by an encircled plus sign.
cleveland_shape_pal(overlap = TRUE) supports four values on either
branch.
cleveland_shape_pal(overlap = FALSE) supports three values by
default and five with unicode = TRUE. Its five source symbols encode
fill fraction, which base pch cannot express, so the two
partially filled circles are dropped rather than approximated by a
different shape. To encode a proportion, map alpha or fill
instead; to restore the five glyphs, use unicode = TRUE with a font
that covers Mathematical Operators, such as STIX Two Text.
The truncation is arguably an improvement. Tremmel (1995) Experiment 2 tested exactly this five-symbol set and found the fill-graded circles the worst performers measured, with the encircled plus and encircled dot the slowest pair and the one producing the most errors. The three shapes that survive are the better-separating subset.
Cleveland WS. The Elements of Graphing Data. Revised Edition. Hobart Press, Summit, NJ, 1994, pp. 154-164, 234-239.
Tremmel, Lothar, (1995) "The Visual Separability of Plotting Symbols in Scatterplots", Journal of Computational and Graphical Statistics, https://www.jstor.org/stable/1390760
Other shapes:
circlefill_shape_pal(),
scale_shape_circlefill(),
scale_shape_cleveland(),
scale_shape_tremmel(),
tremmel_shape_pal()
library("ggplot2")
p <- ggplot(mtcars) +
geom_point(aes(x = wt, y = mpg, shape = factor(gear))) +
facet_wrap(~am) +
theme_bw()
# overlapping symbol palette
p + scale_shape_cleveland()
# non-overlapping symbol palette
p + scale_shape_cleveland(overlap = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.