【问题标题】:Indexing in plot x-axis label in for loop在 for 循环中绘制 x 轴标签中的索引
【发布时间】:2021-01-22 06:23:18
【问题描述】:

我正在用 for 循环的形式进行绘图

for(i in 1:10){
plot(matrix.X, ylab=expression(beta[i]))
}

此代码仅用 Beta_i 标记 10 个地块中的每一个,但我希望 ylabs 为 Beta_1,...,Beta_10。我该如何标记地块?提前致谢!

【问题讨论】:

    标签: r loops plot label


    【解决方案1】:
    for(i in 1:10){
      plot(matrix.X, ylab=paste0("beta_", i)) # you need the paste function
    }
    

    【讨论】:

      猜你喜欢
      • 2016-10-22
      • 1970-01-01
      • 1970-01-01
      • 2021-08-12
      • 2016-04-10
      • 2022-01-01
      • 2020-02-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多