1

I've created a plot with xyplot, which must show two groups of dots and they're regression line.

xyplot(log(Vegetati)~log(Reprod),
       type=c("p", "r"),
       group=Espece,
       data=plantes,
       panel = "panel.superpose",
       auto.key =list(
         points = FALSE, 
         columns=2),
         xlab="log(modules végétatifs)",
         ylab="log(modules reproducteurs)",
        )

I would now add the equations of the two different regression lines, but I don't succeed at combine the panel.superpose function with a panel.text or other. Am I in the wrong way? I can't show the equation AND the two dot's groups with they're line.

Thanks! So, this is a reproductible exemple :

library(lattice)
data(iris)
xyplot(log(Sepal.Width)~log(Sepal.Length), type=c("p", "r"), group=Species,
    data=iris, panel = "panel.superpose")

EDIT : Problem solved! Thank you!

UseR10085
  • 7,120
  • 3
  • 24
  • 54
user2784578
  • 21
  • 1
  • 5
  • Welcome to SO! To improve your chances of getting an answer, please add a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610). If you can't post (parts of) your own data, or simulate data, you can use any of data sets that comes with R (`library(help = "datasets")`). For a small plant example, please have a look at `iris`. – Henrik Sep 16 '13 at 16:30
  • Thanks! So, this is a reproductible exemple : library(lattice) data(iris) xyplot(log(Sepal.Width)~log(Sepal.Length), type=c("p", "r"), group=Species, data=iris, panel = "panel.superpose", auto.key =list( points = FALSE, columns=2), xlab="log(modules végétatifs)", ylab="log(modules reproducteurs)", )` – user2784578 Sep 16 '13 at 16:42
  • Thanks! Please update your _question_ with this example. Then it is much more visible to people that wants to help you, and it is easier to format nicely. Cheers. – Henrik Sep 16 '13 at 16:49

1 Answers1

1

Usually you would write your own custom panel function that delegates to the panel functions you're interested in invoking

panel.my <- function(...) {
    panel.superpose(...)
    panel.text(1, 2, "shoe")  ## or ltext
}

and then use it

xyplot(log(Vegetati)~log(Reprod), type=c("p", "r"), group=Espece, data=plantes, 
    panel = panel.my)

The use of ... passes all arguments seen by panel.my to panel.superpose; you might intercept specific arguments to know which panel you are in, etc., but more details would require that you provide an example that StackOverflow participants (not just you!) can reproduce, e.g., using one of the built-in data sets.

Martin Morgan
  • 45,935
  • 7
  • 84
  • 112