如何用ggplot着色(填充)barplot

时间:2018-08-02 18:33:41

标签: r ggplot2 colors geom-bar

看起来很容易解决(我是使用R的初学者),我已经尝试过scale_fill_manual,但是由于某些原因无法正常工作。

代码如下:

st<-ggplot(df2, aes(x=ES, y=Count.of.ID))
    st+geom_bar(stat = "identity",  na.rm=TRUE, colour = "black") +
scale_fill_manual(values = c("blue", "red", "yellow", "green")) + 
coord_flip() + 
theme_classic() + 
facet_grid(ES.Types~., scales = "free", space = "free") 

enter image description here

我要为与以下内容相关的条涂上颜色:

  • 红色的“文化”
  • “ P”(黄色)
  • “调节中”为绿色
  • “供应”为蓝色

提前谢谢

1 个答案:

答案 0 :(得分:1)

.some-div {
    display: grid;
    /* autoprefixer: off */
    grid-auto-rows: auto auto;
}

enter image description here

相关问题