position_dodge_ {ggmulti} | R Documentation |
Dodge overlapping objects side-to-side
Description
Dodging preserves the vertical position of an geom while adjusting the horizontal position.
position_dodge_()
dodges bars side by side but conditional on locations.
Usage
position_dodge_(width = NULL, preserve = c("total", "single"))
position_dodge2_(
width = NULL,
preserve = c("total", "single"),
padding = 0.1,
reverse = FALSE
)
Arguments
width |
Dodging width, when different to the width of the individual elements. This is useful when you want to align narrow geoms with wider geoms. See the examples. |
preserve |
Should dodging preserve the |
padding |
Padding between elements at the same position. Elements are shrunk by this proportion to allow space between them. Defaults to 0.1. |
reverse |
If |
Details
It is built based on position_dodge
, but used for multiple locations, such as
geom_hist_()
or geom_density_()
. Check examples to see the difference.
See Also
See geom_hist_
and geom_serialaxes_hist
for more examples.
Other position adjustments for multiple locations:
position_identity_
,
position_stack_
, position_fill_
Parent: position_dodge
Examples
if(require(dplyr)) {
p <- iris %>%
tidyr::pivot_longer(cols = -Species,
names_to = "Outer sterile whorls",
values_to = "values") %>%
ggplot(data,
mapping = aes(x = `Outer sterile whorls`,
y = values,
fill = Species))
p + geom_hist_(position = position_dodge_())
}
# all bins are shifted on the left
p +
geom_hist_(position = position_dodge())