Hi Steve,

you need to use the expression() function. I think it is described under ?plotmath. Defo works with mtext, not sure about ylab.

try

ylab(text=c(expression(paste("Hatched Eggs R"^{2}))))

etc.

----- Original Message ----- From: <steve_fried...@nps.gov>
To: <r-help@r-project.org>
Sent: Monday, May 18, 2009 3:25 PM
Subject: [R] Superscripts and subscripts in trellis graphics



I'd like to annotate an xyplot with an R^2 value, but can not find the
syntax to define the superscript format for the text.

I'd appreciate suggestions,

xyplot(SharkSloughEggs.df$Sharkeggs.rel +
SharkSloughEggs.df$SharkHatched.rel + SharkSloughEggs.df$SharkFlooded.rel +
HSI.shark$MEAN ~ Year,
          pch=c(1,9,5,4), lty=c(1,6,3,4), lwd = c(2), col = c("black",
"blue", "green", "red"),
          scales=list(tick.number=length(Year)), data=SharkSloughEggs.df,
ylab="Relative Egg Success",
          main="Shark Slough Alligators",
          par.settings = graph.sets,  type = "b")
                trellis.focus()
                   panel.text(x=1999, y = 0.95, labels="Hatched Eggs\nR^2
= -0.18", cex = 0.75)
                   panel.text(x=1998, y = 0.35, labels="Number of
Eggs\nR^2 = 0.43",cex = 0.75)
                   panel.text(x=1995, y = 0.25, labels="Flooded Eggs\nR^2
= -0.50", cex = 0.75)
                   panel.text(x=1986, y = 0.3, labels="Mean HSI", cex =
0.75)
                trellis.unfocus()


Thanks
Steve


Steve Friedman Ph. D.
Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

steve_fried...@nps.gov
Office (305) 224 - 4282
Fax     (305) 224 - 4147

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to