library(ggplot2)
# geom_bar_connector() -----------
ggplot(diamonds) +
aes(x = clarity, fill = cut) +
geom_bar(width = .5) +
geom_bar_connector(width = .5, linewidth = .25) +
theme_minimal() +
theme(legend.position = "bottom")
# \donttest{
ggplot(diamonds) +
aes(x = clarity, fill = cut) +
geom_bar(width = .5) +
geom_bar_connector(
width = .5,
continuous = TRUE,
colour = "red",
linetype = "dotted",
add_baseline = FALSE,
) +
theme(legend.position = "bottom")
ggplot(diamonds) +
aes(x = clarity, fill = cut) +
geom_bar(width = .5, position = "fill") +
geom_bar_connector(width = .5, position = "fill") +
theme(legend.position = "bottom")
ggplot(diamonds) +
aes(x = clarity, fill = cut) +
geom_bar(width = .5, position = "diverging") +
geom_bar_connector(width = .5, position = "diverging", linewidth = .25) +
theme(legend.position = "bottom")
# geom_connector() -----------
ggplot(mtcars) +
aes(x = wt, y = mpg, colour = factor(cyl)) +
geom_connector() +
geom_point()
ggplot(mtcars) +
aes(x = wt, y = mpg, colour = factor(cyl)) +
geom_connector(continuous = TRUE) +
geom_point()
ggplot(mtcars) +
aes(x = wt, y = mpg, colour = factor(cyl)) +
geom_connector(continuous = TRUE, width = .3) +
geom_point()
ggplot(mtcars) +
aes(x = wt, y = mpg, colour = factor(cyl)) +
geom_connector(width = 0) +
geom_point()
ggplot(mtcars) +
aes(x = wt, y = mpg, colour = factor(cyl)) +
geom_connector(width = Inf) +
geom_point()
ggplot(mtcars) +
aes(x = wt, y = mpg, colour = factor(cyl)) +
geom_connector(width = Inf, continuous = TRUE) +
geom_point()
# }
Run the code above in your browser using DataLab