我试图在使用geom_points制作的ggplot散点图中偏移两个点。我尝试了默认的jitter
以及我自己的设置,但在这两种情况下,我都没有看到情节的差异。情节总是看起来像附图,巴西和墨西哥相当拥挤。 我应该做些什么?
这是我尝试过的代码:
p = ggplot(morning_night, aes(x = ascent_median, y = duration_median)) + geom_point(position = "jitter", aes(color=type, shape=region, size=30))
+geom_text(aes(label=country), hjust = 0, vjust = 1.2)
p = ggplot(morning_night, aes(x = ascent_median, y = duration_median)) + geom_point(position = position_jitter(w=.1, h=.1), aes(color=type, shape=region, size=30))
+geom_text(aes(label=country), hjust = 0, vjust = 1.2)
p = ggplot(morning_night, aes(x = ascent_median, y = duration_median)) + geom_point(position = position_jitter(w=.1, h=.3), aes(color=type, shape=region, size=30))
+geom_text(aes(label=country), hjust = 0, vjust = 1.2)
这是用于此图表的数据框:
country ascent_median duration_median type region
Sweden 41.6 1793 morning Scandinavia
Denmark 33 1960 night Scandinavia
Mexico 75 1877 morning LatinAmerica
Brazil 74.4 1928 night LatinAmerica
Indonesia 41.8 1492 morning SoutheastAsia
Malaysia 48.7 2208 night SoutheastAsia
Switzerland 64.3 2461 morning CentralEurope
Austria 67.9 2113 night CentralEurope