【问题标题】:Change axis label and axis title font size in conditioning plots in R在 R 中的条件图中更改轴标签和轴标题字体大小
【发布时间】:2018-07-20 03:08:39
【问题描述】:

我正在 R 中制作一个条件图,并希望轴标签、轴标题和主标题上的字体大小更大,以便在我将图放入文档时更具可读性。我已经尝试过通常的 cex.lab font.lab 等,但请注意 coplot 的 R 文档指出“参数 xlab 和 ylab 的呈现不受 par 参数 cex.lab 和 font.lab 控制,即使它们是由 mtext 绘制的而不是标题。'

下面粘贴了一些虚拟数据和我用来生成绘图的代码。

c <- c(12, 10, 11, 23, 16, 14, 13, 9, 10)
b <- c(1.23, 1.45, 1.67, 1.76, 1.83, 1.12, 1.43, 1.23, 1.21)
a <- c(13, 15, 16, 22, 23, 26, 31, 19, 25)
coplot(c ~ a | b,number=4, xlab = "a",
   ylab='c', main='Given: b',
   panel = function(x,y,...) {
     points(x,y, pch=4, cex=1.5)
     abline(lm(y ~ x), col='blue', lwd=1.5) 
     abline(lm(WIT ~ age), col='green', lwd=1.5) })

非常感谢您提供有关如何在此处增加字体大小的任何建议。非常感谢。

【问题讨论】:

  • 如果您提供一些玩具数据和运行的代码,会更容易帮助您。你也会得到更好的答案。
  • 感谢您的评论,现在添加了一些玩具数据。

标签: r plot


【解决方案1】:

我不确定我是否理解文档。不管它说什么,在par() 中使用cex.lab 似乎对我有用:

par(cex.lab = 3)  # Default is 1
coplot(WIT ~ age | log(height),
       number=4, 
       xlab = "Age (years)",
       ylab=expression(paste('WIT'[1],' (litres)')), 
       main='Given: Log(height)',
       panel = function(x,y,...) {
         points(x,y, pch=4, cex=1.5)
         abline(lm(y ~ x), col='blue', lwd=1.5) 
        abline(lm(WIT ~ age), col='green', lwd=1.5) }
       )

如果您查看 coplot 函数的源代码(通过运行 coplot 可以看到),这也是有道理的。

【讨论】:

    猜你喜欢
    • 2014-02-19
    • 2022-09-28
    • 2013-02-03
    • 1970-01-01
    • 1970-01-01
    • 2016-04-25
    • 1970-01-01
    • 1970-01-01
    • 2021-07-08
    相关资源
    最近更新 更多