简体   繁体   中英

How can I add just horizontal gridlines in a ggplot in R

图片链接在这里

I want code to add just the horizontal gridlines. I also cant see max values clearly when viewing, is there a way to add extra margin on the side.

Here is an example. theme_void() makes the gridlines disappear (along with the majority of plot items). However, we can manually edit the theme() if we place the function after theme_void() .

library(tidyverse)

ggplot(mtcars,aes(mpg,hp)) + 
  geom_point() + 
  theme_void() + 
  theme(panel.grid.major.y = element_line(),
        panel.grid.minor.y = element_line())

Created on 2022-10-05 by the reprex package (v2.0.1)

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