首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在分位数中标记R usmap

如何在分位数中标记R usmap
EN

Stack Overflow用户
提问于 2020-06-13 23:15:37
回答 1查看 45关注 0票数 0

我已经生成了一个带有代码的地图:

代码语言:javascript
复制
plot_usmap(data = df, values = "ServicePerFFS", color = "red") + 
  scale_fill_continuous(name = "ServicePerFFS (2017)", type = "viridis", label = scales::comma) + 
  theme(legend.position = "right")

但是,我想更改分位数中的标签。我对不同的方式很感兴趣。

代码语言:javascript
复制
 dput(head(df))
    structure(list(abbr = c("AK", "AL", "AR", "AZ", "CA", "CO"), 
    fips = c("02", "01", "05", "04", "06", "08"), full = c("Alaska", 
    "Alabama", "Arkansas", "Arizona", "California", "Colorado"
    ), pop_2015 = c(738432, 4858979, 2978204, 6828065, 39144818, 
    5456574), FFSpop = c(82927, 969116, 593592, 1155335, 5478663, 
    789379), Service = c(413, 7776, 7105, 8856, 64246, 8227), 
    ServicePerFFS = c(4980.28386412146, 8023.80726352676, 11969.5009366703, 
    7665.30919603405, 11726.5836573631, 10422.116625854)), row.names = c(NA, 
6L), class = "data.frame")
EN

回答 1

Stack Overflow用户

发布于 2020-06-14 00:27:51

是像这样吗?

代码语言:javascript
复制
df$ServicePerFFS <- percent_rank(df$ServicePerFFS)

plot_usmap(data = df, values = "ServicePerFFS", color = "red") + 
  scale_fill_continuous(name = "ServicePerFFS (2017)", type = "viridis", label = scales::comma) + 
  theme(legend.position = "right")

编辑:

代码语言:javascript
复制
plot_usmap(data = df, values = "ServicePerFFS", color = "red") + 
  scale_fill_continuous(name = "ServicePerFFS (2017)", type = "viridis", breaks = as.numeric(quantile(df$ServicePerFFS)),labels = paste(round(quantile(df$ServicePerFFS),2),names(quantile(df$ServicePerFFS)), "of ServicePer FFS")) + 
  theme(legend.position = "right") 
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62361727

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档