[英]Wrong fill values in a ggplot2 legend
您可以使用+ guides(fill = guide_legend(override.aes = list(shape = 21)))
手动调整在填充图例(或任何图例)中使用的形状值。 看起来默认值是shape = 1,它不支持填充,因此您只能得到纯黑色形状。
这是mtcars的示例:
ggplot(mtcars) +
geom_point(aes(hp, mpg, fill = as.factor(cyl), shape = as.factor(am))) +
scale_shape_manual(values = c(21,22)) +
guides(fill = guide_legend(override.aes = list(shape = 21)))
用override_aes()
绘制:
情节不包括:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.