首页 文章

cex.axis仅影响y轴,而不影响x轴

提问于
浏览
0

我在子集A1中绘制了因子变量"answer"的图 . 我想减小两个轴上的文本大小,以便在x轴上适合两个极值 . 但是, when using cex.axis, only the font size on the y-label is affected ,不在x轴上 . 为什么会这样,我怎么能改变呢?

我使用的功能是:

plot(A1$answer, main = "Would you recommend edX to a friend of you?", xlab = "Answer", ylab = "#students", col='lightblue', cex.axis=0.75, font=3, family='mono'); box(col='lightblue');

这是输出:

edX recommendation

2 回答

  • 4

    当您在 factor 变量 x 上使用 plot 时,它默认调用 barplot (或更准确地说是 barplot(table(x)) ,即您可以查看 ?barplot 以获取提示 . 在这种情况下,正如我在评论中提到的那样, x-axis 被视为标签,而不是一个数字轴,因此您需要像这样使用 cex.names

    tab <- as.ordered(sample(1:10, 100, replace = TRUE))
    plot(tab, cex.axis = 0.75, cex.names = 0.75)
    

    另外,如上所述,如果要直接使用 barplot ,则需要先创建一个表

    barplot(table(tab), cex.axis = 0.75, cex.names = 0.2)
    
  • 0

    我只是偶然发现了格子中的条形图功能,这有一个更好的输出:

    This is better

相关问题