【发布时间】:2015-08-30 00:45:27
【问题描述】:
南瓜头盔(3.1.2),ggplot2_1.0.0。
library(ggplot2)
some_diamonds <- subset(diamonds, color %in% c('D', 'E', 'F'))
g <- ggplot(some_diamonds, aes(carat, depth, linetype=cut, colour=color)) +
stat_smooth(se=F) + scale_colour_grey()
所需的颜色美感在 color 的图例中正确显示(并且至关重要的是,在情节本身中),但 cut 的颜色默认为 stat_smooth 的默认颜色(蓝色)。 usual tricks 在这种情况下似乎不起作用,例如:
g <- ggplot(some_diamonds, aes(carat, depth, linetype=cut, colour=color)) +
stat_smooth(se=F)
g + scale_colour_grey() + guides(colour = guide_legend(override.aes =
list(colour='black')
事实上,我什至不确定如何访问第二个图例的任何元素。这个
g + scale_colour_grey(guide=guide_legend(title="Title", order=2))
只是将第一个图例的标题更改为“标题”;同样,
g + scale_colour_grey() +
guides(colour=guide_legend(override.aes=list(colour='black'), order=2))
覆盖cut 但不覆盖color,无论order 的值如何(或者即使省略)。
我错过了什么?
【问题讨论】: