Struggling with superscript in plot

Hi, I'm very new to using r and I am using very simple code for my dissertation. However, I cannot get the superscript function to work.

Using ^ doesn't work and only produces the ^ within the axis title/ graph title. I have also used * to follow to close the function. To attempt to solve the issue I have also attempted the subscript function which also doesn't appear to work.

boxplot(Data_for_Box_Plot, main = "Calcium (Ca) mgKg-1", xlab = "Fertiliser Category", ylab = "mgKg-1", outcold = "red")
This is my code, and I am trying to get the -1 as a superscript on both main and ylab.

Any help would be really appreciated.

I think the post here will help address your problem using the expression() function:
https://www.dataanalytics.org.uk/axis-labels-in-r-plots-using-expression/

Excerpting below (though you'll probably want to look at the whole page, which isn't terribly long):

Superscript & subscript

The most common thing you’ll want to do in axis labels is to make superscripts and subscripts.

  • ^ Anything following the caret is displayed as superscript.
  • [] Anything inside the square brackets is displayed as subscript.

The [] are simple enough to use, anything that you want to be subscripted goes inside the brackets.

Note that you cannot start an expression() with a [ so you have to “fool” the system and use a pair of empty quotes:

expression(""[x]*X)

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.