Mayby你正在尋找theme_bw()
ggplot(df, aes(x, y)) + geom_point() + theme_bw()
這裏是theme_classic()
ggplot(df, aes(x, y)) +
geom_point() +
theme_classic() +
theme(
axis.line.x = element_line(colour = "grey50"),
axis.line.y = element_line(colour = "grey50")
)
當一個人需要看到一個主題的結構的解決方案,它可以輸出其價值與dput:
dput(theme_classic())
這讓您會看到結果列表中的哪些名稱具有正在執行「消隱」的代碼:
theme_classic()[grepl("axis.line", names(theme_classic()))]
$axis.line
List of 4
$ colour : chr "black"
$ size : NULL
$ linetype: NULL
$ lineend : NULL
- attr(*, "class")= chr [1:2] "element_line" "element"
$axis.line.x
list()
- attr(*, "class")= chr [1:2] "element_blank" "element"
$axis.line.y
list()
- attr(*, "class")= chr [1:2] "element_blank" "element"
你是否從cowplot那裏得到了這個? 'theme_classic'給你提供什麼文檔http://docs.ggplot2.org/current/ggtheme.html'ggplot(diamonds,aes(clarity,fill = cut))+ geom_bar()+ cowplot :: theme_cowplot() ' – rawr
這工作在ggplot 2.0.0,但不再在ggplot 2.1.0中工作。儘管如此,您仍然可以通過添加'+ theme(axis.line.x = element_line(color =「black」),axis.line.y = element_line(color =「black」))來治癒。也許他們在[theme-defaults.r]中改變了一些東西(https://github.com/hadley/ggplot2/blob/master/R/theme-defaults.r) – lukeA
一個bug:看看[here](http:// stackoverflow.com/questions/35833307/ggplo2-axis-not-showing-after-using-themeaxis-line-element- line/35833548#35833548)和[bug報告](https://github.com/hadley/ggplot2 /問題/ 1565)。 –