简体   繁体   English

使用 ggplot2 的 plot_usmap 时,如何将比例设置为静态窃取动态

[英]How do I set the scale to be static insteal of dynamic when using ggplot2's plot_usmap

I am trying to have my legend's scale be consistent across nine different plots.我试图让我的传奇规模在九个不同的地块中保持一致。 Currently the scale changes for each plot.目前,每个地块的比例都会发生变化。 Here is the code for the first two plots:这是前两个图的代码:

plot_usmap(data = january, values="tot_cases", color="black") +
  scale_fill_gradient2(low = "blue", high = "red", name = "Total Cases", label = scales::comma,) +
  theme(legend.position = "right",panel.background = element_rect(color = "black", fill = "lightblue"))

plot_usmap(data = february, values="tot_cases", color="black") +
  scale_fill_gradient2(low = "blue", high = "red", name = "Total Cases", label = scales::comma) +
  theme(legend.position = "right",panel.background = element_rect(color = "black", fill = "lightblue"))

How can I get the scales to be the same for all my plots?我怎样才能让所有地块的比例都相同?

Like @stefan said, add the limits parameter which takes 2 numbers, min and max.就像@stefan 所说的,添加需要 2 个数字的限制参数,最小值和最大值。 plot_usmap(data = january, values="tot_cases", color="black") + scale_fill_gradient2(low = "blue", high = "red", name = "Total Cases", label = scales::comma, limits = c(MIN, MAX)) + theme(legend.position = "right",panel.background = element_rect(color = "black", fill = "lightblue")) plot_usmap(data = january, values="tot_cases", color="black") + scale_fill_gradient2(low = "blue", high = "red", name = "Total Cases", label = scales::comma, limits = c (MIN, MAX)) + 主题(legend.position = "right",panel.background = element_rect(color = "black", fill = "lightblue"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM