0

我想用 ggplot 制作一个点图(条形图),但代码似乎将这些点堆叠在一起。没有更多的变化:(。有人知道我该如何解决这个问题吗?

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() 
4

1 回答 1

1

尝试这个

dp <- ggplot(df, aes(x = Month, y = Ratio, fill = City)) +
 geom_dotplot(position = position_jitter(width = 0.1, height = 0.1)) 
dp

您可能更喜欢位置“闪避”

dp <- ggplot(df, aes(x = Month, y = Ratio, fill = City)) +
geom_dotplot(position = "dodge") 
dp

有关更多信息,请参阅http://ggplot2.tidyverse.org/reference/position_dodge.html

于 2017-10-17T16:41:48.200 回答