我正在try 给分组的条形图赋予相同 colored颜色 的不同深浅,这些条形图也是多面的.
以下是我已经拥有的代码和输出:
temp.data = data.frame (Species = rep(c("A","B"),each=2, times=2),
Status = rep(c("An","Bac"), times=4),
Sex = rep(c("Male","Female"), each=4, times=1),
Proportion = c(6.86, 7.65, 30.13, 35.71, 7.13, 10.33, 29.24, 31.09))
ggplot(temp.data, aes(x = Species, y = Proportion, fill = Status, alpha = Species)) +
geom_bar(stat='identity', position = position_dodge(width = 0.73), width=.67) +
facet_grid(Sex ~ .) + xlab("X title") +
ylab("Y title") +
scale_fill_manual(name = "Status", labels = c("An","Bac"),
values = c("#86a681","#0a3e03")) +
scale_alpha_manual(values = c(0.6, 1)) +
theme_light() + theme(legend.title= element_text(size = 8),
legend.title.align=0.5,
legend.position = c(),
legend.background=element_blank(),
legend.text=element_text(size=7),
legend.key.size = unit(0.6, 'cm'),
axis.title.x = element_text(size = 9),
axis.title.y = element_text(size = 9),
axis.title.y.right = element_text("Sex of groups"),
strip.background = element_rect(
color="lightgrey", fill="white", size=0.5, linetype="solid"),
strip.text.y = element_text(color = "darkgrey", face = "bold"))
然而,我在这里找不到一个答案来为不同的wine 吧群体分配不同的 colored颜色 .我终于想出了scale_alpha_manual()
的函数,但它不能手动赋予 colored颜色 ,它应该是定义的"填充"的阿尔法刻度.因此,这个问题在这里也不是重复的问题.
Here's how the desired output should seem like (preferably with the legends):
提前谢谢你了.