R 在ggplot2中设置面板背景色后,面板网格线消失

R 在ggplot2中设置面板背景色后,面板网格线消失,r,ggplot2,R,Ggplot2,我用ggplot2做了一个阴谋。将面板背景色修改为白色(或其他颜色,甚至透明)后,网格线消失。我怎样才能取回面板网格线?多谢各位 ggplot(mtcars, aes(x=wt, y=hp))+ geom_point()+ theme(panel.background = element_rect(fill = 'white')) # or other color, or 'transparent' 默认情况下,网格线也是白色的,因此如果面板背景为白色,您当然无法看到它们 gg

我用ggplot2做了一个阴谋。将面板背景色修改为白色(或其他颜色,甚至透明)后,网格线消失。我怎样才能取回面板网格线?多谢各位

ggplot(mtcars, aes(x=wt, y=hp))+
    geom_point()+
    theme(panel.background = element_rect(fill = 'white')) # or other color, or 'transparent'

默认情况下,网格线也是白色的,因此如果面板背景为白色,您当然无法看到它们

ggplot(mtcars, aes(x=wt, y=hp))+
  geom_point()+
  theme(panel.background = element_rect(fill = 'white'),
        panel.grid.major = element_line(color = 'black'),
        panel.grid.minor = element_line(color = 'grey'))

默认情况下,网格线也是白色的,因此如果面板背景为白色,您当然无法看到它们

ggplot(mtcars, aes(x=wt, y=hp))+
  geom_point()+
  theme(panel.background = element_rect(fill = 'white'),
        panel.grid.major = element_line(color = 'black'),
        panel.grid.minor = element_line(color = 'grey'))

您也可以尝试
theme\u bw()
theme\u classic()
您也可以尝试
theme\u bw()
theme\u classic()