Adding superscripts to plot

The superscripts can be added to the x or y axes labels or titles of the plot. These can be added using the ^ operator which is appended to the character string created in the plot() method. The superscript operator can be created using the expression method. 

Syntax:

expression(str^val)

Parameters : 

  • str – The character string to create
  • val – The value to raise the character string by

Example:

Here we are going to create a plot with numbers from 1 to 6 with power of 2 as an expression.The string “Numbers” is combined with a subscript ^2 formatted with ^ symbol. 

R




# creating numbers
numb < - 1: 6
  
# creating the x axis labels
# creating a plot
plot(numb, xlab=expression("Numbers" ^ 2))


Output:

How to Add Superscripts and Subscripts to Plots in R?

Plots can be used to create and display numerical values or data points. The x and y axes labels or titles are used to depict the labels to the plot data. These labels can create either subscript or superscript symbols within them. This can be done using various base R methods : 

Similar Reads

Method 1: Adding superscripts to plot

The superscripts can be added to the x or y axes labels or titles of the plot. These can be added using the ^ operator which is appended to the character string created in the plot() method. The superscript operator can be created using the expression method....

Method 2: Adding subscripts to plot

...

Method 3: Adding both superscripts and subscripts to plot

The subscripts can be added to the x or y axes labels or titles of the plot. These can be added using the [] operator which is appended to the character string created in the plot() method. The subscript operator can be created using the expression method....

Contact Us