English · PDF 486
) ggplot(df, aes(x, y)) + geom_hex() + coord_fixed() #> 正在加载所需的包:methods ggplot(df, aes(x, y)) + geom_hex() + viridis::scale_fill_viridis() + coord_fixed()
请注意,所有颜色标度都有两种形式:scale_color_x() 和 scale_fill_x(),分别对应 color 和 fill 美学(这些颜色标度同时提供英式和美式拼写)。
ggplot(df, aes(x, y)) + geom_hex() + scale_color_gradient(low = "white", high = "red") + coord_fixed()
ggplot(diamonds, aes(carat, price)) + geom_point(aes(color = cut), alpha = 1/20)