问题描述
正如标题所说。
当我将连续值映射到映射时,它会很好地工作。
当我将离散值映射到映射时,它也能很好地工作。
但是当我将这两层结合在一起时,会发生错误:
错误:将离散值提供给连续刻度
library(scatterpie)
library(tidyverse)
library(geosphere)
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 <- ggplot(us,aes(long,lat))
# mapping temperautre value to map
p + geom_map(map = us,aes(map_id = region,fill = temp),color = 'grey')
# mapping pie chart to map
p +
geom_map(map = us,aes(map_id = region),color = 'grey') +
geom_scatterpie(data = category_data,lat),cols = c("cat_1","cat_2","cat_3"),alpha = 0.5)
# mapping temperautre and pie chart simultaneously
# ERROR OCCUR
# Error: discrete value supplied to continuous scale
p + geom_map(map = us,color = 'grey') +
geom_scatterpie(data = category_data,alpha = 0.5)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)