R语言迭代gera斜体

标签 r plot title italics

抱歉问了这个非常愚蠢的问题,我已经用谷歌搜索了一段时间但没有找到解决方案。我需要迭代地创建几个图,其标题是(1)从之前创建的向量中选取的,(2)必须是斜体的。 我尝试了几种选择,但没有得到足够的结果,如下所示:

# Main titles
m <- paste(LETTERS[1:10], LETTERS[11:20])
# Plots
for(i in 1:10){
     x <- runif(10, 1, 20)
     y <- runif(10, 1, 20)
     X11()
     plot(x,y, main = expression(italic(m[i])))
}

但是我得到的是带有“m”和“i”作为下标的图,而不是向量中的相应内容。有什么想法吗?

最佳答案

这是实现你想要的目标的方法

# Main titles
m <- paste(LETTERS[1:10], LETTERS[11:20])
# Plots
for(i in 1:10){
  x <- runif(10, 1, 20)
  y <- runif(10, 1, 20)
  X11()
  plot(x,y, main = substitute(paste(italic(x)), list(x = m[i])))
}

其中一个情节 enter image description here

关于R语言迭代gera斜体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66801339/

相关文章:

matlab - 如何更改 Matlab 图中线条的顺序?

python - 在 Plotly 的 Scattergeo 图中制作图例

html - div 为 :target 时更改页面标题

r - R中的调用函数是什么?

r - 使用 kable 和 knitr 保留 table() 中的行/列标签

r - 网格线与轴上的刻度一致

python - 消除高于和低于某个值的地 block 值

css - 使用 html iframe 时显示标题标签 "popup"

android - 如何检测对 ActionBar 标题的点击?

r - R 中的成对误差估计产生错误的乘积