如何避免geom_scatterpie函数重叠

问题描述

我已经看到答案Pie charts in geom_scatterpie overlapping

但是我不想手动重置重叠的饼图坐标。

ggplot2中是否有某些函数,或者其他什么可以避免geom_scatterpie()函数中的重叠?

任何帮助将不胜感激!

可复制的代码在这里

library(scatterpie)
library(tidyverse)
library(geosphere)
library(ggnewscale)


us <- map_data('state') %>% as_tibble()

n = length(unique(us$region))

# creat fake mapping data

temperature_data <- tibble(region = unique(us$region),temp = rnorm(n = n))

coords <- us %>% select(long,lat,region) %>% distinct(region,.keep_all = T)

category_data <- tibble(region = unique(us$region),cat_1 = sample(1:100,size = n),cat_2 = sample(1:100,cat_3 = sample(1:100,size = n)) %>% left_join(coords)

us <- left_join(us,temperature_data)

p + 
  geom_map(map = us,aes(map_id = region,fill = temp),color = 'grey') +
  new_scale('fill') +
  geom_scatterpie(data = category_data,aes(long,lat),cols = c("cat_1","cat_2","cat_3"),alpha = 0.5)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)