【发布时间】:2016-11-09 09:15:25
【问题描述】:
我怎样才能使条(代表处理“B1”和“D1a”)不同的颜色。它们现在都是红色的,例如,我如何使 B1 红色(在浅红色下堆叠粗体红色)和 D1a 蓝色(在浅蓝色下堆叠粗体蓝色)?
到目前为止,这是我的脚本:
#glucose
x<-data.frame(
Period = c("B1","D1a"),
Sample = c("Glucose","Glucose"),
Mi = c(34.01497478, 7.616569764),
M0 = c(116.6844713,11.88958888)
)
mx <- melt(x, id.vars=1:2)
mx <- mx %>% group_by(Period) %>%
mutate(pos = cumsum(value)) %>%
ungroup() %>%
mutate(ci = c(1.773332238, 1.0661239, 6.083212937, 1.664236691),
upper = pos + ci/2,
lower = pos - ci/2)
b<-ggplot(mx, aes(x=Period, y=value, fill=variable), xLabels=NA) +
geom_bar(stat="identity", width=0.65, aes(alpha=variable)) +
scale_alpha_manual(values=c(0.9,0.35)) +
geom_errorbar(aes(ymin = lower, ymax = upper), width = .3,size = 0.6, col = "black") +
facet_grid(~Sample) +
scale_fill_manual(values = c("red","red")) +
theme_bw() +
xlab("") +
ylab("")
b+theme(axis.text=element_text(size=20),
axis.title=element_text(size=22,face="bold"),
text = element_text(size=45),
legend.position="none")
非常感谢。
【问题讨论】: