Carrie Perkins
Carrie Perkins

Reputation: 139

Pie charts in geom_scatterpie overlapping

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"))

pie charts
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))

jittered pies

Upvotes: 2

Views: 1656

Answers (1)

Roman
Roman

Reputation: 4989

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

Upvotes: 0

Related Questions