[英]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.