Highlight specific bars depending of a factor
I would like highlight some specifics bars in my barplot depending of a factor.
In this example:
dat <- read.table(text = "sam_760 sam_1541 sam_723 sam_727
1 19.5 12 8.7 5.77
3 3.84 0 5.8 7.62", header = TRUE)
barplot(as.matrix(dat))
The sam_760 bar have a factor == 84, the sam_1541 == 25, sam_723 == 12 and sam_727 == 15. I thought in some color scale from grey to red highlighting the sam_760 in example, however would be nice other scale suggestions.
Anyway, Thank you very much!
• 4,134 views
•
link
1 answer
Using border you can set an extra layer of color to your barplots.
I would suggest, adding another row of factors for the variables and plotting using ggplot library, which gives much more control over the plots.
Check geom_bar for doing this, in conjugation with melt function from the library reshape.
• 0 views
•
link
Log in to answer this question.