如何在R绘图函数cdplot()中设置轴的字体大小
我有一个简单的绘图调用:如何在R绘图函数cdplot()中设置轴的字体大小,r,formatting,plot,R,Formatting,Plot,我有一个简单的绘图调用: cdplot(example~test) 我想把轴的字体调大一些。但是, cdplot(example~test, cex=2.0) 不起作用,我也找不到解决办法。如何增加字体大小?使用par功能来避免此问题: #example data from ?cdplot: fail <- factor(c(2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1
cdplot(example~test)
我想把轴的字体调大一些。但是,
cdplot(example~test, cex=2.0)
不起作用,我也找不到解决办法。如何增加字体大小?使用
par
功能来避免此问题:
#example data from ?cdplot:
fail <- factor(c(2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1,
1, 2, 1, 1, 1, 1, 1),
levels = 1:2, labels = c("no", "yes"))
temperature <- c(53, 57, 58, 63, 66, 67, 67, 67, 68, 69, 70, 70,
70, 70, 72, 73, 75, 75, 76, 76, 78, 79, 81)
#save old parameters
old.par <- par(no.readonly = TRUE)
#change only the size of axis, for axis labels use cex.lab etc, see ?par
par(cex.axis=2)
cdplot(fail ~ temperature)
par(old.par) #restore old parameters
#cdplot中的示例数据:
失败另一种选择是破解cdplot
函数,设置cex.axis
。但我不鼓励黑客的功能,即使在这里它是一个简单的功能。Myabe最好联系软件包维护人员以添加axis字体功能
使用getS3method('cdplot','default')
获得函数源,并将此行更改为:
Axis(xorig, side = 1,cex.axis=cex.x)
equidist <- any(diff(y1[, 1L]) < tol.ylab)
if (equidist)
axis(2, at = seq.int(1/(2 * ny), 1 - 1/(2 * ny),
by = 1/ny), labels = yaxlabels, tick = FALSE,cex.axis=cex.y)
else axis(2, at = (y1[-1L, 1L] + y1[-NROW(y1), 1L])/2,
labels = yaxlabels, tick = FALSE,cex.axis=cex.y)
工作得很好。非常感谢你@agstudy当然你是对的,par(cex.axis=2)
会为axis tick标签做这件事,par(cex.lab=2)
会为axis标签做这件事吗?
my.cdplot(y=fail ,x=temperature,cex.x=2,cex.y=3)