Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to "split bars" in barplot with R?

Tags:

r

I have a barplot beside = T. What I need is to split (or draw an horizontal line) at each height "marks" of each bars.

Sample matrix to plot :

    > head(top.fem)
        FD1 FE2 FF1
    J01   2   2  10
    J02   4   0   0
    J03   6   2   5
    J04   1   6   3
    J05  10  10   2
    J06   9   6   5

I simply :

barplot(top.fem,beside = T)

So, for FD1, bar 1 has a height of 2, bar 2 height of 1 and bar 3 height of 6 ect... How to split bar 1 in two, bar two in 4 and bar 3 in 6 ? The results would "look like" a stacked bar plot but it is not. Am I being clear ?

Thanx for any help !

like image 498
Chargaff Avatar asked Mar 08 '26 01:03

Chargaff


1 Answers

You can add horizontal lines on the whole picture: if they are white, and if the background is white, they will remain unnoticed.

barplot(VADeaths, beside=TRUE, las=1)
abline(h=0:100, col="white")
barplot(
  VADeaths, beside=TRUE, las=1,
  add=TRUE, col=FALSE
)

barplot

like image 65
Vincent Zoonekynd Avatar answered Mar 09 '26 15:03

Vincent Zoonekynd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!