Pie charts in geom_scatterpie overlapping

自闭症网瘾萝莉.ら 提交于 2021-01-29 20:12:17

问题


I would like to find a way to keep pie charts in scatterpie from overlapping with one another. I know that I can further reduce the radius, but don't want to make them any smaller than they already are. Position=jitter does not work well at all.

Here is a reproducible example:

library(ggplot2)
library(ggmap)
library(scatterpie)


data=data.frame(lat=c(52,52,51.5),long=c(4.1,5.5,6),radius=c(5,10,13),A=c(0.2,0.2,0.2),B=c(0.8,0.8,0.8))

map=get_map(location=c(3,50,7,54),source="google")
ggmap(map) + 
  geom_scatterpie(data=data,aes(x=long,y=lat,r=radius/20),cols=c("A","B"))


Adding position=position_jitter does not work:

ggmap(map) + 
  geom_scatterpie(data=data,aes(x=long,y=lat,r=radius/20),cols=c("A","B"),position = position_jitter(w = 0.4,h=0))


回答1:


Adjust your lat and long coordinates, e.g.

data = data.frame(lat = c(52, 52.4, 51.8),
                  long = c(4.1, 5, 6),
                  radius = c(5, 10, 13),
                  A = c(0.2, 0.2, 0.2),
                  B = c(0.8, 0.8, 0.8))


来源:https://stackoverflow.com/questions/52806580/pie-charts-in-geom-scatterpie-overlapping

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!