我很迷惑.在标题,标签和绘图的其他位置增加文本字体大小的正确方法是什么?
例如
x <- rnorm(100)
hist(x, xlim=range(x), xlab= "Variable Label",
ylab="density", main="Title of plot", prob=TRUE, ps=30)
Run Code Online (Sandbox Code Playgroud)
该ps参数不会改变字体大小(但它在R帮助中?par表示它是"文本的点大小(但不是符号)").
还可以将字体大小从绘图功能中分离出来,例如hist?
Dir*_*tel 134
你想要像cex=1.5缩放字体150%的参数.而是看到了help(par)作为也有cex.lab,cex.axis...
Jer*_*lim 117
因此,总结现有的讨论,补充说
cex.lab=1.5, cex.axis=1.5, cex.main=1.5, cex.sub=1.5
你的情节,其中1.5可能是2,3等,而值为1是默认会增加字体大小.
x <- rnorm(100)
Run Code Online (Sandbox Code Playgroud)
hist(x, xlim=range(x),
xlab= "Variable Lable", ylab="density", main="Title of plot", prob=TRUE)
hist(x, xlim=range(x),
xlab= "Variable Lable", ylab="density", main="Title of plot", prob=TRUE,
cex=1.5)
Run Code Online (Sandbox Code Playgroud)

hist(x, xlim=range(x),
xlab= "Variable Lable", ylab="density", main="Title of plot", prob=TRUE,
cex.lab=1.5, cex.axis=1.5, cex.main=1.5, cex.sub=1.5)
Run Code Online (Sandbox Code Playgroud)

小智 21
请注意,当使用文本制作绘图时," cex "确实会改变.例如,凝聚层次聚类的图:
library(cluster)
data(votes.repub)
agn1 <- agnes(votes.repub, metric = "manhattan", stand = TRUE)
plot(agn1, which.plots=2)
Run Code Online (Sandbox Code Playgroud)
将生成具有正常大小文本的图:

并plot(agn1, which.plots=2, cex=0.5)会产生这样一个:

Urb*_*ond 20
通过反复试验,我确定了设置字体大小需要以下内容:
cex不起作用hist().使用cex.axis了在轴上的数字,cex.lab为标签.cexaxis()两者都不起作用.使用cex.axis了在轴上的数字.hist()时可以设置标签来代替设置标签mtext().您可以使用设置字体大小cex,但使用值1 实际上将字体设置为默认值的1.5倍!您需要使用cex=2/3以获取默认字体大小.至少,使用PDF输出,在Mac OS X的R 3.0.2下就是这种情况.pointsizein 更改PDF输出的默认字体大小pdf().我认为,假设R(a)实际上做了它的文档应该做的事情,(b)以预期的方式表现,这太合乎逻辑了.
当我想让轴标签变小时,我遇到了这个问题,但让其他所有东西都保持相同的大小。对我有用的命令是:
par(cex.axis=0.5)
Run Code Online (Sandbox Code Playgroud)
在 plot 命令之前。只记得放:
par(cex.axis=1.0)
Run Code Online (Sandbox Code Playgroud)
绘图后确保字体恢复到默认大小。