简体   繁体   中英

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)

在此处输入图像描述

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

Best.

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)

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