rggplot2data-visualizationgridlinesggthemes

How can I make y-axis lines that match the x-axis lines from theme_clean()?


I'm going to be producing a lot of visuals for a report. My boss really likes the theme_clean() horizontal lines but wants me to add the same lines to the x-axis. Is there an easy way to do this?

Here is my code

library(ggplot2)
library(ggthemes)

ggplot(mtcars, aes(x = mpg)) + 
  geom_point(aes(y = hp)) + 
  theme_clean(base_size=18)

enter image description here

How can I get the same style for my x-axis ticks (going vertical).

Best.


Solution

  • Try this. Simply typing theme_clean into the console shows you the default values used by theme_clean for panel.grid.major.y which we then can use to set the values for panel.grid.major.x accordingly using theme():

    library(ggplot2)
    library(ggthemes)
    
    ggplot(mtcars, aes(x = mpg)) + 
      geom_point(aes(y = hp)) + 
      theme_clean(base_size=18) + 
      theme(panel.grid.major.x = element_line(colour = "gray", linetype = "dotted"))
    

    Created on 2020-04-07 by the reprex package (v0.3.0)