X and Y labels titles help

Anyone here know how to add a subscript or superscript to a axis label? For example like in the photo. I can't find these commands anywehere :confused:
I want to add them all at once but I don't know how.


How I can label x and y axis like in the photo?
It's normal plot.

Take a look at documentation for plotmath and run

demo(plotmath)

in your console.

x <- seq(1,2)
y <- seq(21,22)
plot(x, y, xlab = expression(paste("C"[3], bgroup("[",over("mol","m"^3), "]"))), 
     cex.axis = 0.5)

Created on 2019-04-12 by the reprex package (v0.2.1)

2 Likes

plot(x,y, xlab="",
mtext(side=1, line=4, expression(paste("c"[HIO[3]], bgroup("[",over("mol","m"^3), "]")))),
ylab=expression(paste("V", bgroup("[", "s"^-1, "]"))),
main="wyrkes zalez", col="black", pch=16,
cex.lab=1,
cex.axis=0.7
)

Rplot

Now I have something like this. I figured out how to move xaxis label but i don't know how to move yaxis label closer to axis. I've tried mtext() but R says:""Error in mtext(side = 2, line = 1, expression(paste("V", bgroup("[", "s"^-1, :
plot.new has not been called yet"

What can I do to move X and Y axis at one time?

One solution is with the title() function.

x <- seq(1,5)
y <- seq(1,5)
plot(x,y, xlab="",
     mtext(side=1, line=4, expression(paste("c"[HIO[3]], bgroup("[",over("mol","m"^3), "]")))),
     ylab = "",
     main="wyrkes zalez", col="black", pch=16,
     cex.lab=1,
     cex.axis=0.7
     
)
title(ylab = expression(paste("V", bgroup("[", "s"^-1, "]"))), line = 2)

Created on 2019-04-13 by the reprex package (v0.2.1)

1 Like

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.