[英]R usmap - how to show two different colors: one for gradients in positive value while the other show the negative value
显然我没有你的数据,所以我编造了一些。 您应该能够使用scale_fill_gradientn
获得您想要的:
library(usmap)
df2 <- usmap::statepop
df2$diffProviderPerFFS <- runif(nrow(df2), -0.2, 0.5)
plot_usmap(data = df2, values = "diffProviderPerFFS", color = "white") +
scale_fill_gradientn(name = "Provider Per 1000 FFS(2017-2016)",
colours = c("red", "white", "forestgreen"),
breaks = c(-0.2, 0, 0.2),
label = scales::comma) +
theme(legend.position = "right")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.