How can i write H2o in the title of a plot?
H2 works:
plot(main=expression("H"[2]),0)
H2O fails:
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)
How can i write H2o in the title of a plot?
H2 works:
plot(main=expression("H"[2]),0)
H2O fails:
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))
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.