R 跨多个绘图固定绘图填充比例

R 跨多个绘图固定绘图填充比例,r,ggplot2,R,Ggplot2,基于此,我尝试绘制多年的彩色编码地图。考虑下面的最小例子: library(ggplot2) states <- map_data("state") var <- data.frame(table(states$region)) var$x1 = runif(49, 5.0, 7.5) var$x2 = 2+runif(49, 5.0, 7.5) states$x1 <- var$x1[match(states$region,var$Var1)] states$x2 <-

基于此,我尝试绘制多年的彩色编码地图。考虑下面的最小例子:

library(ggplot2)
states <- map_data("state")
var <- data.frame(table(states$region))
var$x1 = runif(49, 5.0, 7.5)
var$x2 = 2+runif(49, 5.0, 7.5)
states$x1 <- var$x1[match(states$region,var$Var1)]
states$x2 <- var$x2[match(states$region,var$Var1)]

## first plot
map <- ggplot(states, aes(x=long, y=lat,fill=x1,group=group))+ geom_polygon()
map = map + scale_fill_gradient(low='white', high='grey20')
print(map)

## second plot
map <- ggplot(states, aes(x=long, y=lat,fill=x2,group=group))+ geom_polygon()
map = map + scale_fill_gradient(low='white', high='grey20')
print(map)
库(ggplot2)

州将限制添加到
比例填充梯度

map <- ggplot(states, aes(x=long, y=lat,fill=x1,group=group))+ geom_polygon()
map = map + scale_fill_gradient(low='white', high='grey20', limits=c(1, 10))
print(map)

map <- ggplot(states, aes(x=long, y=lat,fill=x2,group=group))+ geom_polygon()
map = map + scale_fill_gradient(low='white', high='grey20', limits=c(1, 10))
print(map)

map我似乎错过了帮助页面中的此选项!谢谢