问题
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