我想以不同方式为我的boxplot变量着色。我看了here并尝试了下面的内容,但是绘图框都是标准的白色(我在Type中有6个因子)。我应该改变什么?
library(ggplot2)
ggplot(PGcounts, aes(Type, Word)) +
geom_boxplot() +
coord_trans(y = "log10") +
scale_fill_manual(values = c("white","white","white","red","blue","white"))
答案 0 :(得分:1)
您也可以在原始代码中从geom_boxplot()
更改为geom_boxplot(aes(fill=Type))
。
例如:
ggplot(PGcounts, aes(Type, Word)) +
geom_boxplot(aes(fill=Type)) +
coord_trans(y = "log10") +
scale_fill_manual(values = c("white","white","white","red","blue","white"))
答案 1 :(得分:0)
需要改变的是
geom_boxplot() +
到
geom_boxplot(fill = c("white","white","white","red","blue","white")) +
并删除
scale_fill_manual(values = c("white","white","white","red","blue","white"))