R boxplot这个手册怎么填错了
R boxplot how is this manual fill wrong
我想用不同的方式为箱线图变量着色。我查看了 here 并尝试了以下内容,但绘图框都是标准的白色(我在类型中有 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"))
需要改变的是
geom_boxplot() +
到
geom_boxplot(fill = c("white","white","white","red","blue","white")) +
并删除
scale_fill_manual(values = c("white","white","white","red","blue","white"))
您也可以将原始代码中的 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"))
我想用不同的方式为箱线图变量着色。我查看了 here 并尝试了以下内容,但绘图框都是标准的白色(我在类型中有 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"))
需要改变的是
geom_boxplot() +
到
geom_boxplot(fill = c("white","white","white","red","blue","white")) +
并删除
scale_fill_manual(values = c("white","white","white","red","blue","white"))
您也可以将原始代码中的 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"))