在R基本图中,将轴标签移近轴 [英] In R base plot, move axis label closer to axis

查看:129
本文介绍了在R基本图中,将轴标签移近轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经删除了y轴上的标签,因为只有相对数量才是真正重要的.

I have eliminated labels on the y axis because only the relative amount is really important.

w <- c(34170,24911,20323,14290,9605,7803,7113,6031,5140,4469)
plot(1:length(w), w, type="b", xlab="Number of clusters",
     ylab="Within-cluster variance",
     main="K=5 eliminates most of the within-cluster variance",
     cex.main=1.5,
     cex.lab=1.2,
     font.main=20,
     yaxt='n',lab=c(length(w),5,7), # no ticks on y axis, all ticks on x
     family="Calibri Light")

但是,抑制那些刻度标签会在y轴标签(簇内差异")和y轴之间留出许多空白.有没有办法将其推回原位?如果我以某种方式将(不可见的)刻度标签设置在轴的 内,轴标签是否会沿轴固定?

However, suppressing those tick labels leaves a lot of white space between the y axis label ("Within-cluster variance") and the y axis. Is there a way to nudge it back over? If I somehow set the (invisible) tick labels to go inside the axis, would the axis label settles along the axis?

推荐答案

尝试在plot调用中设置ylab="",并使用title手动设置y轴的标签.使用line,您可以调整标签的位置,例如:

Try setting ylab="" in your plot call and use title to set the label of the y-axis manually. Using line you could adjust the position of the label, e.g.:

plot(1:length(w), w, type="b", xlab="Number of clusters", ylab="",
     main="K=5 eliminates most of the within-cluster variance",
     cex.main=1.5,
     cex.lab=1.2,
     font.main=20,
     yaxt='n',lab=c(length(w),5,7), # no ticks on y axis, all ticks on x
     family="Calibri Light")

title(ylab="Within-cluster variance", line=0, cex.lab=1.2, family="Calibri Light")

有关详细信息,请阅读?title.

Please read ?title for more details.

这篇关于在R基本图中,将轴标签移近轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆