geom_bar: color gradient and cross hatches (using gridSVG), transparency issue

前端 未结 2 637
小蘑菇
小蘑菇 2021-02-06 12:52

Using the awesome ggplot package, I want a barplot where the fill aesthetic is mapped to a continous variable, actually qvalues and on top of it a text

2条回答
  •  Happy的楠姐
    2021-02-06 13:51

    I am answering my own question, as there is a way to fill a specific color to the pattern thank to this link. On the first bar, for category "A", it could look like this: cross

    replacing the pat1 pattern by the following code:

    pat1 <- pattern(gTree(children=gList(
                          rectGrob(gp=gpar(col=NA, fill=cols[4])),
                          linesGrob(gp=gpar(col="black", lwd = 5)))),
                          width = unit(5, "mm"), height = unit(5, "mm"),
                          dev.width = 1, dev.height = 1)
    

    For geom_bar with few colours, it would work but for my issue where the fill colour is mapped to a heatmap scale, it is going to be tedious.

提交回复
热议问题