Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scatterpie shape changes with the map from ggmap #27

Open
smallfishcui opened this issue Jan 7, 2020 · 7 comments
Open

scatterpie shape changes with the map from ggmap #27

smallfishcui opened this issue Jan 7, 2020 · 7 comments

Comments

@smallfishcui
Copy link

smallfishcui commented Jan 7, 2020

Hi,

I have been using the scatterpie package with ggmap package, aiming to show the genetic admixture on the map, here is my code:
library(tidyverse)
library(ggplot2)
library(ggmap)
library(scatterpie)
register_google(key = "xxxxx", write = TRUE)
d<-read.table("/Users/cuiwang/Desktop/map/Phmap.txt", header=TRUE)
a<-get_googlemap(center = c(mean(d$lon), mean(d$lat)), zoom = 1)
a<- ggmap(a)
a + geom_scatterpie(aes(x=long, y=lat,r=2), data=d, cols=c("Usnat","Usland","Med","AU","CN","EU"), color="#252728", alpha=1)

However, I got a picture with the pie chart skewed, as if it is also projected in the same way of the map. Is there any solution for this?
image

@kfuku52
Copy link

kfuku52 commented Dec 2, 2020

I came across a similar problem in combining scatterpie with ggtree + cowplot. The orange pie charts in the middle were generated by scatterpie but its aspect ratio cannot be easily adjusted. I would appreciate it if anybody could tell me a solution to force the pie charts perfect circle.
image

@Kamouyiaraki
Copy link

Hi I'm here with the same issue, hoping someone will see this to offer some insight!

@PGmajev
Copy link

PGmajev commented Mar 9, 2021

This is also true when using geom_sf() and coord_sf()

@martinpastoors
Copy link

martinpastoors commented Dec 9, 2021

I have a similar issue trying to plot proportions on a map. This is using coord_quickmap(xlim=xlim, ylim=ylim):
image
If I use coord_equal, the problem disappears:
image

@madelynore
Copy link

hi! I have this same issue. Has anyone figured out a solution to this problem?

@GuangchuangYu
Copy link
Member

use +coord_equal().

@madelynore
Copy link

Thanks, coord_equal() did not work for me, because I'm working maps plotted with WGS84 coordinate system and I get this error:

Coordinate system already present. Adding new coordinate system, which will replace the existing one.

But I did figure out a workaround, by projecting everything into NAD83, and that solved the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants