Remove top and right borders from boxplot in R

Does anyone know how to remove the top and right borders of a boxplot frame in R? I tried argument frame = FALSE, but removes all the parties, but the left side (axis y). I just want to be the x-axis and y-axis appear.

Thanks in advance!

+6
source share
2 answers

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

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

This gives

enter image description here

+2
source

To remove ticks, you need to specify the width of the tick line as zero (lwd.ticks = 0). To ensure that the x and y axes match, it will be much harder for you

  • specify the lower limit of the axis y, using ylim = ...
  • specify the height of the axis of x, using pos = ...
  • expanding the x-axis to the axis y - one way is to simply add a horizontal line using abline.

Combining it all together for the example above:

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

Barplot with frame removed

0
source

All Articles