This could be achieved by switching to a lighter color or by reducing the opacity of the color used for the grid lines which both could be achieved via theme option panel.grid
. Below I show the second approach. Unfortunately element_line
has no alpha
argument to set the opacity but you could adjust it via the hex color code:
I make use of the default grid line color "grey92" which has rgb values (235, 235, 235).
To set the opacity I use rgb()
which as a fourth argument takes the opacity or alpha which I reduce to a value of 100:
library(ggplot2)
library(dplyr)
data = mtcars
# Reduce the opacity of the grid lines: Default is 255
col_grid <- rgb(235, 235, 235, 100, maxColorValue = 255)
data %>%
select(mpg, disp) %>%
ggplot(aes(disp, mpg))+
geom_point(size = 3)+
theme_bw() +
theme(panel.grid = element_line(color = col_grid))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…