geom_scatterpie重叠中的饼图 [英] Pie charts in geom_scatterpie overlapping

查看:89
本文介绍了geom_scatterpie重叠中的饼图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找到一种方法,以防止散点图中的饼形图相互重叠.我知道我可以进一步减小半径,但是不希望将它们设置得比现在更小.位置=抖动根本无法正常工作.

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.

以下是可重现的示例:

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


添加 position = position_jitter 不起作用:

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

推荐答案

调整您的 lat long 坐标,例如

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

这篇关于geom_scatterpie重叠中的饼图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆