[英]Dotchart / Stripchart / Dotplot GGplot stacks dots on top of each other. How can I fix this?
I want to make a dotplot (stripchart) with ggplot, but the code seems to stack the dots on top of each other. 我想用ggplot制作一个dotplot(stripchart),但是代码似乎将点堆叠在一起。 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 有关更多信息,请参见http://ggplot2.tidyverse.org/reference/position_dodge.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.