I plotted a facet graph using qplot and I used “fill” option to color the bars based on their values(high=Red, med=violet, low=blue)
https://i.stack.imgur.com/raEzA.png
My code is:
x = qplot(as.character(exon),Divergence_from_Average, data=HRA_LR,
geom="histogram",fill=abs(Divergence_from_Average))
y = x +facet_grid(~probeset_id, scales="free_x", space= "free") + theme_bw() +
opts(title="GRP78/HSPA5 (HRN vs LR)")
If I only need to color the bars which is above 0.3 and leave rest of the unfilled how can I do that?
You can tweak this to suit your needs, but here’s the basic concept:
We’ll define a new binary variable that determines whether or not to fill the bars. We’ll pass that into the
fillargument as a factor and usescale_colour_manualto give them the colours we want. I also passed set thecolourparameter to red so that you can see the white bars on the white background.Will generate something like this. I forgot to
set.seed()before saving the image so your miles may vary, but consider this a proof of concept: