Different starting point (not 0) in the dash line of the Y-axis?

I am trying to create a simple histogram that includes two bars showing the average math grades of two groups of students. The average values ​​are 363.2 and 377.4. creating a histogram is easy. I would like to have my y axis start with 340, not 0. I know how to change the limits of the y axis, but the problem is that I change the limit of the y axis to c (340, 380), R still draws the entire rod, most of which is below the x axis!

Here is my code:

barplot(c(363.2, 377.4), beside = T, ylim = c(340,380), col = c("orange", "blue"))

I also attached my plot:

+5
source share
2 answers

Adding xpd=FALSEand re-adding jobs along the horizontal axis, for example:

b <- barplot(c(363.2, 377.4), beside = TRUE, 
   ylim = c(340,380), col = c("orange", "blue"),xpd=FALSE)
axis(side=1,at=b,labels=c("group 1", "group 2"))
box(bty="l")

( , Googling " " , , , , ), , : , , ( , R : . ). , , , , ; .

, ", , "...

+7

?barplot:

:

"xpd: logical. ?"

xpd=FALSE -.

+2

All Articles