如何用ggplot2改变轴标签和蜱标签之间的间距?

时间:2022-07-08 14:55:07

This seems a very basic question but I can't find the answer: how to change the default spacing between the axis main label and the axis ticks label? I have looked through theme documentation but could find only the axis.ticks.margin option which lets set the spacing between ticks and ticks label.

这似乎是一个非常基本的问题,但我找不到答案:如何更改轴主标签和轴刻度标签之间的默认间隔?我查看了主题文档,但只能找到axis.tick。空白选项,让设置间隔之间的蜱和蜱之间的标签。

For example,

例如,

df <- data.frame(x = 1:5, y = seq(from=1, l = 5))
ggplot(df, aes(x,y)) + geom_line()

produces the following:

产生以下:

如何用ggplot2改变轴标签和蜱标签之间的间距?

where I'd like to add more space between the label y and the axis (y and 3 are too close for me).

我想在标签y和轴之间增加更多的空间(y和3离我太近了)。

1 个解决方案

#1


3  

You can try this as well

你也可以试试这个

df <- data.frame(x = 1:5, y = seq(from=1, l = 5))
ggplot(df, aes(x,y)) + geom_line()+
    ylab("y\n\n")

#1


3  

You can try this as well

你也可以试试这个

df <- data.frame(x = 1:5, y = seq(from=1, l = 5))
ggplot(df, aes(x,y)) + geom_line()+
    ylab("y\n\n")