Removing top and right borders from boxplot frame in R Removing top and right borders from boxplot frame in R r r

Removing top and right borders from boxplot frame in R


I think you need to use axis(side=1) after plotting.

x <- 1:5boxplot(x, frame.plot = FALSE)axis(side = 1)

This gives

enter image description here


  1. Plot without axes
    boxplot(x, axes=F)
  1. Add a box of type "l" (that's an L, not a 1), like thelatemail suggested
    box(bty="l")
  1. Add axis ticks at desired values.
    axis(2)    axis(1) #if you really want x-axis ticks here...

enter image description here


To remove ticks, you need to specify the ticks line width as zero (lwd.ticks=0). To ensure the x and y axes meet is a bit more laborious, you need to

  1. specify the lower limit of the y axis using ylim=...
  2. specify the height of the x axis using pos=...
  3. extend the x axis to the y axis - one way is simply to add a horizontal line using abline.

Putting that all together for the example above:

x <- 1:5boxplot(x, frame.plot = FALSE,ylim=c(0,5))axis(side=1, pos=0, lwd.ticks=0)abline(h=0)

Barplot with frame removed