I want to make a dotplot (stripchart) with ggplot, but the code seems to stack the dots on top of each other. There is no more variation :(. Anyone know how I can fix this?
df <- data.frame(City = c("AMS", "AMS", "AMS", "AMS", "BEL", "BEL", "BEL", "BEL"),
Month = c(4, 5, 6, 7, 4, 5, 6, 7),
Ratio = c(8, 9, 10, 5, 12, 13, 9, 10))
dp <- ggplot(df, aes(x = Month, y = Ratio, fill = City)) +
geom_dotplot()
Try this
dp <- ggplot(df, aes(x = Month, y = Ratio, fill = City)) +
geom_dotplot(position = position_jitter(width = 0.1, height = 0.1))
dp
You may prefer position "dodge"
dp <- ggplot(df, aes(x = Month, y = Ratio, fill = City)) +
geom_dotplot(position = "dodge")
dp
For more info see http://ggplot2.tidyverse.org/reference/position_dodge.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.