1
ggplot(data = filter(My.Map, Year == 1435 & Some.Factor == 1), aes(x=long, y=lat, group = Group.Var, fill=as.numeric(Ageincrease))) +
geom_polygon() +
scale_fill_continuous(name="Age increase") +
geom_path(color = "white") +
coord_equal() +
coord_quickmap()
不幸的是没有示例的数据。我的数据包含一个变量 - Ageincrease,我想在地图上填充为contionous。如果是正面的,蓝色,如果是负面的红色。但也是渐变,边上有2个色条。 Some.Factor是我创建的变量,用于指示Ageincrease是否为负值/正值。GGPLOT2:取决于因子颜色长期最高变量也