I want to plot my data over US map and also add pie charts on the map. I used geom_polygon and also plot_usmap with geom_scatterpie but none of them worked. This my data https://iastate.box.com/s/rllzhkfmab475zr4ywur56cd31jhwl8g
f1<-ggplot() + geom_scatterpie(aes(x, y, group = region),
data = total, cols = "fuel",pie_scale = 1.3, long_format=TRUE) +
facet_grid(growth ~ emission)+
geom_text(aes(x, y, label = region),size = 4,family = "serif",
data = total, vjust = 1.2, nudge_y = -100000,check_overlap = TRUE)+
scale_fill_manual(legend_title,values=mypal[names(mypal) %in% total[,2]])+
theme(legend.title = element_text(family="sans",face = "bold", size = 12), legend.text = element_text(family="sans",size = 11),legend.position = "bottom")+
theme(strip.text = element_text(family="sans",size = 14))+
theme(panel.background = element_rect(fill = NA, color = "gray"))
f1+ggplot(states_data, aes(x, y, fill = value, group = group)) +
geom_polygon()+
scale_fill_continuous(low = "white", high = "red", name = "Ele gen (EJ)", label =
scales::comma) +
facet_grid(growth ~ emission) +
coord_equal() +
ggthemes::theme_map() +
theme(legend.position = "bottom")
and also this
plot_usmap(data=states_data,values = "value", regions = "states", exclude = c("AK", "HI"))
+scale_fill_continuous(low = "white", high = "red", name = "Ele gen (EJ)", label =
scales::comma)+
geom_scatterpie(aes(x, y, group = region),
data = total, cols = "fuel",pie_scale = 1.3, long_format=TRUE) +
facet_grid(growth ~ emission)+
geom_text(aes(x, y, label = region),size = 4,family = "serif",
data = total, vjust = 1.2, nudge_y = -100000,check_overlap = TRUE)+
scale_fill_manual(legend_title,values=mypal[names(mypal) %in% total[,2]])+
theme(legend.title = element_text(family="sans",face = "bold", size = 12),
legend.text = element_text(family="sans",size = 11),legend.position = "bottom")+
theme(strip.text = element_text(family="sans",size = 14))+
theme(panel.background = element_rect(fill = NA, color = "gray"))