以mtcars为示例数据。只需设置间断点和/或标签,如下所示:
library(ggplot2)
ggplot(mtcars, aes(cyl, mpg, color = hp)) +
geom_point() +
scale_color_continuous(breaks = c(100, 200, 300), labels = c("low", "med", "high"))
由reprex package (v0.3.0)于2020年03月14日创建
library(ggplot2)
ggplot(mtcars, aes(cyl, mpg, color = hp)) +
geom_point() +
scale_color_continuous(type = "viridis",
breaks = c(100, 200, 300), labels = c("low", "med", "high"))