简体   繁体   中英

how to adjust panel.borders in ggplot?

I have drawn a simple barplot:

mtcars$cnames = rownames(mtcars)
ggplot(mtcars[1:5,], aes(cnames, disp)) + 
  geom_bar(stat = "identity") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 0.5),
        panel.border = element_rect(colour = "black", fill=NA, size=5))

and as you can see by running this example borders are going thrugh the axis.text. How to make borders lower?

Hope this is what are you looking for :

  mtcars$cnames = rownames(mtcars)
ggplot(mtcars[1:5,], aes(cnames, disp)) + 
    geom_bar(stat = "identity") +
    theme_minimal() +
    theme(axis.text.x = element_text(angle = 45, hjust = 0.5),
          plot.background = element_rect(colour = "black", fill=NA, size=5))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM