Skip to content

two colors and putting lines on bar plots

2 messages · John Malone, Greg Snow

#
For the first question you can use %in% rather than ==, for example:

ifelse( dataframe$vector_o_number %in% c('00','01), 'red', 'black') 

for the reference line, the abline function will draw a line the full width/height of a graph for a general reference, if you want separate lines for each group of bars then the segments function will draw the shorter lines.  Note that the return value of the barplot function gives information on the x coordinates of the bars that could be useful in drawing the lines (see the examples for barplot).

Hope this helps,