连续性变量作为color映射。
library(ggplot2)
library(RColorBrewer)
set.seed(1)
df <- data.frame(x = runif(100), y = runif(100), z = runif(100))
cols <- rev(brewer.pal(11, 'RdYlBu'))
ggplot(df, aes(x, y, colour = z)) +
geom_point()+
scale_colour_gradientn(colours = cols)
网友评论