我有一個簡單的情節電話怎麼辦:我設置的字體大小在R繪圖功能cdplot軸()
cdplot(example~test)
我想使軸更大的字體。但是,
cdplot(example~test, cex=2.0)
不起作用,我無法找到解決方案。如何增加字體大小?
我有一個簡單的情節電話怎麼辦:我設置的字體大小在R繪圖功能cdplot軸()
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
的論點部分:
體重,N,來自於...參數傳遞給密度。
而且從?density
的論點部分:
...的(非默認)方法的進一步論證。
所以你不能使用cdplot(fail ~ temperature,cex.axis=2)
因爲附加參數「...
」由density
功能不把它們作爲圖形參數,如cex
使用。
另一種選擇是破解cdplot
函數,設置cex.axis
。但我不鼓勵黑客功能,即使在這裏它是一個簡單的功能。 My更好地聯繫包維護者添加軸字體功能。
使用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)
我創建了一個新的gist新功能。
例如:
my.cdplot(y=fail ,x=temperature,cex.x=2,cex.y=3)
完美地工作。非常感謝! – collisionTwo 2013-03-14 07:57:02
@agstudy所以只需設置par(cex.lab = 2.0)'。 – 2013-03-14 08:02:25
@agstudy當然你是對的,'par(cex.axis = 2)'會做軸標記標籤,'par(cex.lab = 2)'會做它的軸標籤嗎? – 2013-03-14 08:08:37