ggplot2 - remove panel top border
06:30 20 Jan 2020

I'm want to remove only the top part of my graph. I found some directions here and here. However, they remove all the borders or the top and left. I know that I should probably use the argument panel.border with element_blank() or element_rect() but I cannot find the correct way to define it.

I'm looking for this:

enter image description here

library(tidyverse)

mtcars %>% 
  ggplot(aes(factor(cyl), disp)) + 
  geom_boxplot() + 
  jtools::theme_apa() + 
  theme(
    panel.border = element_blank())

Will results with:

enter image description here

r ggplot2