| show_cutoffs | R Documentation |
show_cutoffs(
object = NULL,
part,
color = "#1e3a8a",
size = 4,
show_labels = FALSE
)
object |
A ggplot of one distribution – a histogram, bar chart, density,
dotplot, or |
part |
A distribution part, e.g. |
color |
Marker/line color. Default |
size |
Marker size. Default |
show_labels |
Whether to annotate the cutoffs. Default |
Adds empirical quantile cutoffs for a distribution part – middle(),
tails(), upper(), lower(), or outer(). Short dashed stems end in
downward triangles that touch the numeric axis. Optional callouts are drawn
in the data panel. Repeated labelled calls are measured and placed together.
Their boxes stay separate when the panel has room, and their routed leaders
remain tied to the exact cutoffs.
In very small panels, leaders use a simple elbow connection if there is no
room for an outward route. Labels keep their text and size, so they may
overlap or be clipped. Enlarge the figure, use fewer facet columns, or set
show_labels = FALSE when labels do not fit.
By default the part is read off the plot's fill aesthetic, e.g.
fill = ~middle(Thumb, .95). Passing part overrides that reading: it marks
whatever part is named there instead, and the fill (if any) is ignored –
marking the 99% cutoffs on a plot shaded for the 95% is a deliberate, lossless
override, not a mismatch.
show_cutoffs() refuses a plot whose first layer does not draw a distribution
(a scatterplot, for instance) and, when part is given explicitly, a part
that names a variable other than the one the plot puts on x.
A ggplot object with cutoff markers and optional labels.
stat_cutoff() computes the same rule per panel; geom_cutoff()
is the lower-level drawing component. guide_cutoff() can place cutoff
anchors in a position guide instead.
gf_histogram(~Thumb, data = Fingers, binwidth = 5, fill = ~middle(Thumb, .95)) %>%
show_cutoffs(show_labels = TRUE)
# an explicit part overrides the fill instead of requiring it to match
gf_histogram(~Thumb, data = Fingers, binwidth = 5, fill = ~middle(Thumb, .95)) %>%
show_cutoffs(middle(Thumb, .99))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.