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:取決於因子顏色長期最高變量也