View source: R/position-dodge-.R
position_dodge_ | R Documentation |
Dodging preserves the vertical position of an geom while adjusting the horizontal position.
position_dodge_()
dodges bars side by side but conditional on locations.
position_dodge_(width = NULL, preserve = c("total", "single"))
position_dodge2_(
width = NULL,
preserve = c("total", "single"),
padding = 0.1,
reverse = FALSE
)
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 |
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 geom_hist_
and geom_serialaxes_hist
for more examples.
Other position adjustments for multiple locations:
position_identity_
,
position_stack_
, position_fill_
Parent: position_dodge
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())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.