[英]ggplot2: How to adjust fill colour in a boxplot (and change legend text)?
我怎樣才能:
將圖例文本從“0”,“1”更改為其他內容?
require(ggplot2) ggplot(mtcars, aes(factor(cyl), mpg)) + geom_boxplot(aes(fill=factor(vs), colour=c("grey50", "white")))
您需要調整填充美感,而不是顏色美感。 您可以通過調整比例來處理您的兩個問題(以及更多):
ggplot(mtcars, aes(factor(cyl), mpg, fill = factor(vs))) +
geom_boxplot() +
scale_fill_manual(name = "This is my title", values = c("pink", "green")
, labels = c("0" = "Foo", "1" = "Bar"))
對於GGPLOT2網站幫助頁面scale_manual是滿不錯的例子。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.