Description Usage Arguments Value See Also Examples
View source: R/position_dodgex.r
Dodging preserves the vertical position of an geom while adjusting the
horizontal position. position_dodgex2
is a special case of position_dodgex
for arranging box plots, which can have variable widths. position_dodgex2
also works with bars and rectangles. But unlike position_dodgex
,
position_dodgex2
works without a grouping variable in a layer.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
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. |
hexpand |
numeric, Horizon expand for geoms that have a position, default is NA. |
vexpand |
numeric, Vertical expand for geoms that have a position, default is NA. |
preserve |
Should dodging preserve the total width of all elements at a position, or the width of a single element? |
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 |
position methods
Other position adjustments:
position_identityx()
,
position_points_sinax()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | library(ggplot2)
library(patchwork)
iris$ID <- rep(c(rep("test1", 15), rep("test2", 15), rep("test3", 20)),3)
p <- ggplot(iris, aes(x=Species,y=Petal.Length,fill=ID))
p1 <- p + geom_bar(stat="identity",position=position_dodgex())
p2 <- p + geom_bar(stat="identity",position=position_dodgex(vexpand=5))
p3 <- ggplot(iris, aes(x=Petal.Length, y=Species, fill=ID)) +
geom_bar(stat="identity", orientation="y",
position=position_dodgex(hexpand=5))
p4 <- p1 + p2 + p3
p4
p5 <- p + geom_boxplot(position=position_dodgex2())
p6 <- p + geom_boxplot(position=position_dodgex2(vexpand=5))
p7 <- ggplot(iris, aes(x=Petal.Length, y=Species, fill=ID)) +
geom_boxplot(orientation="y",
position=position_dodgex2(hexpand=5))
p8 <- p5 + p6 + p7
p8
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.