我在ggplot中制作了一些情节,下面是一个颜色条图例 . 默认情况下,图例只有4个标签显示特定颜色的值 . 有些主题元素可以改变颜色条的大小,但不能改变标签的数量 . 如何增加标签数量?
library(ggplot2) ggplot(mtcars, aes(x=mpg, y=carb, color=disp)) + geom_point(size=3) + theme(legend.key.height = unit(2,'cm'))
你只需要在 scale_color_continous() 中指定 breaks
scale_color_continous()
breaks
g1 <- ggplot(mtcars, aes(x=mpg, y=carb, color=disp)) + geom_point(size=3) + theme(legend.key.height = unit(2,'cm')) g1 + scale_color_continuous(breaks=seq(50,500,25))
1 回答
你只需要在
scale_color_continous()
中指定breaks