I like to use it for prepare the plot, add horizontal lines and finally plot the bars. When I do it like below, R plots every thing twice and this looks not so nice. For a normal plot the equivalent I search is: plot(NULL, xlim=c(1,2), ylim=c(3,5), axes=F)
data = c(1,4,2)
barplot(data)
abline(h=seq(0,5,1), col="red")
barplot(data, add=T)
I prefer to have a base solution.
Plotting with col
and border
set to NA
and axes = FALSE
will effectively create an empty plot. Then you can add abline
and actual barplot
data = c(1,4,2)
barplot(data, col = NA, border = NA, axes = FALSE)
abline(h=0:5, col="red")
barplot(data, add = TRUE)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With