我想用ggplot创建一个dotplot(stripchart),但代码似乎将点堆叠在一起。没有更多变化:(。任何人都知道如何解决这个问题?
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()
答案 0 :(得分:1)
试试这个
dp <- ggplot(df, aes(x = Month, y = Ratio, fill = City)) +
geom_dotplot(position = position_jitter(width = 0.1, height = 0.1))
dp
您可能更喜欢位置&#34;闪避&#34;
dp <- ggplot(df, aes(x = Month, y = Ratio, fill = City)) +
geom_dotplot(position = "dodge")
dp
有关详细信息,请参阅http://ggplot2.tidyverse.org/reference/position_dodge.html