当用R中的`as.factor`绘图时,为什么`ann = F`不起作用?

DQd*_*dlM 4 plot r r-factor

我正在使用plot()R 中的因子绘制连续变量(参见下面的示例).我不想要轴上的标签.如果没有as.factor公式中的调用,ann = F则会禁止打印标签,但as.factor在公式中不起作用.

为什么是这样?

谢谢.

# example for SO
# example data 
x <- sample(1:100, 10)
y <- c(rep(1, 5), rep(2, 5))

# ann = F doesn't work here
plot(x ~ as.factor(y), ann = F)

# ann = F does work here
plot(x ~ y, ann = F)
Run Code Online (Sandbox Code Playgroud)

Jos*_*ich 5

它似乎是plot.formula由于它是有效的,如果您指定xy单独:

plot(as.factor(y), x, ann=FALSE)
Run Code Online (Sandbox Code Playgroud)

更新:

确认它在graphics:::plot.formula.调用plot显式设置的行ylabxlab(funnameis "plot"dots= list(ann=FALSE)):

do.call(funname, c(list(mf[[i]], y, ylab = yl, xlab = xl), dots))
Run Code Online (Sandbox Code Playgroud)