axis.ticks.length()
来设置绘图区域和轴文本之间的间距,因为您选择不显示刻度线(axis.ticks=element_blank()
)。ggplot(dfr,aes(x,y))+
geom_point()+
theme(axis.title=element_blank(),
axis.ticks.length = unit(.85, "cm"),
axis.ticks=element_blank())
或者,您可以定义margin()
的参数(t、r、b、l)来调整空间。
ggplot(dfr,aes(x,y))+
geom_point()+
theme(axis.title=element_blank(),
axis.ticks=element_blank(),
axis.text.x=element_text(margin = margin(t = 20)),
axis.text.y=element_text(margin = margin(r = 20)))
axis.title.y
替换为axis.text.y
,以实现增加y轴上文本与标题之间的距离。原文链接请见:Increase distance between text and title on the y-axis。 - Henrik