如何仅在 R 中堆叠条的特定部分更改颜色?

问题描述

我有一个关于仅在堆叠条的某些部分提供颜色的问题。

Genotype <- c(rep("CV_A",3),rep("CV_B",rep("CV_A",3))
treatment <- c("CTRL","BT","AN","CTRL","AN")
ratio <- c(rep("x",6),rep("y",6))
value <- c(1,0.81,1,0.99,0.71,0.94,0.17,0.18,0.15,0.009,0.28,0.05)
dataA <- data.frame (Genotype,treatment,ratio,value)

ggplot(data=dataA,aes(x=treatment,y=value,fill=ratio))+
  geom_bar(stat="identity",position = position_stack(reverse = T),width = 0.7,size=1) + 
  geom_hline(yintercept=1,linetype="solid",color = "Blue") +
  scale_fill_manual(values= c ("DarkSlateGray","dark red")) +
  scale_y_continuous(breaks = seq(0,1.5,0.3),limits = c(0,1.5)) +
  facet_wrap(~Genotype)

enter image description here

现在我只想在线下方的部分给出蓝色,而在线上方的部分仍然保持红色。你能告诉我怎么做吗?

另外,我可以在不使用 facet_wrap(~Genotype) 的情况下制作图表吗?我的意思是在一个面板(而不是像这样的两个面板)中,我想展示所有条形图。

非常感谢!!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)