答案 0 :(得分:0)
使用以下代码
library(ggthemes)
ggplot(mtcars, aes(mpg, hp)) +
geom_point() + theme_hc() +
theme(axis.line.y = element_blank(), axis.line.x = element_line())
如果您想根据自己的密码给出答案,
ggplot(mtcars, aes(mpg, hp)) +
geom_point() +
theme_clean()+
theme(axis.line.y = element_blank(), axis.line.x = element_line(), plot.background=element_blank())
答案 1 :(得分:0)
尝试一下(使用theme_classic
,这有点接近您想要的结果,但是同时具有x和y轴线):
ggplot(mtcars, aes(mpg, hp)) +
geom_point() + theme_classic() +
theme(axis.line.y = element_blank(), axis.line.x = element_line())
如果键入theme_classic
(不带括号),则可以看到用于创建该主题的所有theme
元素。请注意,经典主题已应用axis.line
,该主题同时创建了x和y轴线。如果您尝试仅 指定axix.line.y = element_blank()
,则该命令将不起作用,因为theme_classic()
将axis.line
应用于该命令,从而再次出现了两行。这就是为什么您必须在此处指定两者的原因。