r - 如何在分位数中标记 R usmap
问题描述
我用代码生成了一张地图:
plot_usmap(data = df, values = "ServicePerFFS", color = "red") +
scale_fill_continuous(name = "ServicePerFFS (2017)", type = "viridis", label = scales::comma) +
theme(legend.position = "right")
但是,我想更改分位数的标签。我对这样做的不同方式感兴趣。
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")
解决方案
像这样?
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")
编辑:
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")
推荐阅读
- reactjs - React Native: Uncaught (in promise) 错误: DeltaPatcher 在初始化时应该收到一个基础 Bundle
- javascript - 如何获取深度嵌入元素相对于根元素本身的 x 和 y 位置?
- c# - winform TableLayoutPanel 有一些行,但其中只有一个是可见的
- java - Java CEF IntelliJ 插件在 init (Linux) 上支持 UnsatisfiedLinkError
- python - TypeError:“日期时间”类型的对象不是 JSON 可序列化的(带有序列化功能)
- javascript - Javascript:长按文件对话框
- python - 这本书的章节索引提取程序有改进吗?
- python-3.x - 如何从其他文件夹导入 python 模块
- javascript - javascript中的百分比,然后从百分比反转为targetValue
- c# - 在 Azure Bot Framework 的 WaterfallDialog 中,我们如何进行特定步骤?