Пример (не содержит GGPLOT2) :
data("mtcars")
counts <- table(mtcars$gear)
barplot(counts, main="Car Distribution",
xlab="Number of Gears")
axis(1, # Put 1 for X-axis, 2 for Y-axis
at=c(0, 5), #Limit of line
col="red",
line=2.5, # how much gap you need between line and X-axis
labels=rep("",2), # remove line labels
lwd=2,
lwd.ticks=0) # remove ticks
Несколько строк, просто добавьте еще одну команду axis
как -
data("mtcars")
counts <- table(mtcars$gear)
barplot(counts, main="Car Distribution",
xlab="Number of Gears")
axis(1, # Put 1 for X-axis, 2 for Y-axis
at=c(0, 2.5), #Limit of line
col="red",
line=2.5, # how much gap you need between line and X-axis
labels=rep("",2), # remove line labels
lwd=2,
lwd.ticks=0) # remove ticks
axis(1, # Put 1 for X-axis, 2 for Y-axis
at=3+c(0, 2.5), #Limit of line
col="blue",
line=2.5, # how much gap you need between line and X-axis
labels=rep("",2), # remove line labels
lwd=2,
lwd.ticks=0) # remove ticks