1

I need to add superscript to my R lattice graph labels, specifically with "m^2".

equivalence.xyplot(mydata$IsoCanopyArea ~ mydata$ControlCanopyArea,
                   alpha=0.05, b0.ii=0.25, b1.ii=0.25,
                   xlab= "ISODATA (m^2)",
                   ylab= "Measured (m^2)") 

This function uses lattice graphics, so the typical commands do not seem to work:

plot(0, ylab = ~ "AddTextHere" (m^2))

I have looked at several examples on this site with no success: example1 and example2 (Note I am a different Aaron than the OP in example2)

How can accomplish superscripts in lattice graph labels?

Community
  • 1
  • 1
Borealis
  • 8,044
  • 17
  • 64
  • 112
  • Typically axis labels should be supplied as characters, expressions or something else that can be converted to a character or an expression. However, `~"AddTextHere" (m^2))` creates an object of class `formula`. My guess is that the standard `plot` function automatically converts it to an expression, but `xyplot` does not and just ignore it. – Backlin Oct 23 '12 at 15:10

2 Answers2

4

Use expression as in:

plot(...
    xlab=expression("ISODATA " (m^2))
    ylab= expression("Measured" (m^2))
....)
Jilber Urbina
  • 58,147
  • 10
  • 114
  • 138
1

Based on the solution from @Jilber, the following changes to the graph worked:

equivalence.xyplot(mydata$IsoCanopyArea ~ mydata$ControlCanopyArea,
                   alpha=0.05, b0.ii=0.25, b1.ii=0.25,
                   xlab= expression("ISODATA " (m^2)),
                   ylab= expression("Measured " (m^2)))

enter image description here

Borealis
  • 8,044
  • 17
  • 64
  • 112