GNU R 绘图标题中的化学式(或数学表达式) [英] Chemical formula (or mathematical expression) in GNU R plot title

查看:30
本文介绍了GNU R 绘图标题中的化学式(或数学表达式)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在情节标题中写 H2o?

How can i write H2o in the title of a plot?

H2 有效:

plot(main=expression("H"[2]),0)

H2O 失败:

plot(main=expression("H"[2]"O"),0)

此解决方案仅适用于"前有空格的情况

This solution will work only, if i have a space in front " "

plot(main=expression(" "*H[2]*"O"),0)

推荐答案

你已经接近了.这有效:

You were close. This works:

plot(1:10, main = expression(H[2]*O))

这样做的原因是 2 是元素 H 的下标,并且您希望将元素 O 放在 旁边>H.表达式中的符号 x * y 表示将 xy 并列,即放置 xy 在一起.请参阅 ?plotmath 了解更多信息.

The reason for this is that the 2 is a subscript to element H and you want to position element O next to the H. The notation x * y in an expression means juxtapose x with y, i.e. place x and y together. See ?plotmath for more.

这篇关于GNU R 绘图标题中的化学式(或数学表达式)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆