【问题标题】:Multiple line breaks in expression表达式中有多个换行符
【发布时间】:2014-01-30 19:12:48
【问题描述】:

我需要添加多个换行符,但我在expression() 中的 atop 函数上遇到了困难,因为我只能添加一个换行符:

main=expression(atop("Fig. 3. Total yearly diffuse attenuation coefficient at","490 nm (K"[d]*") and chlorophyll concentration at 3 coral reef sites between 2003 and 2012")

【问题讨论】:

  • expression( atop( "a", atop( "b", "c" ) ) ) 工作吗?
  • 确实如此,但文本变得越来越小。有其他选择吗?

标签: r expression


【解决方案1】:

一种解决方法是使用textstyle 以正常大小绘制:

plot(1,1,main=expression(
  atop(textstyle("a"),
    atop(textstyle("b"),
         textstyle("c")
    )
  )
))

一个可能更清晰的解决方案是多次使用mtext,每行一次:

plot(1,1)
mtext(expression(bold("Fig. 3. Total yearly diffuse attenuation coefficient")), line=3)
mtext(expression(bold("at 490 nm (K"[d]*") and chlorophyll concentration")), line=1.9)
mtext(expression(bold("at 3 coral reef sites between 2003 and 2012")), line=1)

请注意,在第二行中,我使用了line=1.9 来稍微纠正由于下标引起的间距:

【讨论】:

  • 感谢您修复了垂直定位问题。需要注意的另一点是这些 expression 参数中不需要引号
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-13
  • 2013-08-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-10
相关资源
最近更新 更多