Hi:
On Mon, Oct 18, 2010 at 11:32 PM, Cristina Ramalho <
cristina.ramalho@grs.uwa.edu.au> wrote:
> Hi all,
>
> I suppose this is a very simple question, but as I've lost already a
bit of
> time with it, without being able to get what I wanted, I'm addressing
the
> question to the group in the hope someone can help me.
>
> I pretend to plot the richness of herbaceous species (RichHN) as a function
> of time since remnant isolation (Isol) conditioned to the area of the
> remnant (fArea - this is a factor with 3 classes). I also want to
> differentiate the sites plotted using a grouping binary variable (Urb).
>
> So far, I've written this:
>
> extinction<-xyplot(RichHN~Isol|fArea, data = Data, type = "p",
groups=Urb,
> aspect="xy", layout=c(3,1), between=list(x=0.5, y=0.5),
> cex=1, pch = c(21, 1),
> auto.key=list(space="bottom"),
> main="Influence of time since remnant isolation and remnant
area
> on species diversity",
> xlab="Time since remnant isolation (rank)",
> ylab="Richness of native herbaceous")
> print(extinction)
>
> What do I need to add, in order I can have:
> - the graph dots labeled with the variable SiteName
>
This isn't a simple fix - I believe you need to create a panel function and
use panel.text() in conjunction with panel.xyplot(). The trick is figuring
out the coordinates to place the labels relative to the points.
- an overall trend line for each panel>
Use type = c('p', 'r') - the 'r' stands for least
squares fitted line
between the x and y variables. With groups defined, there is a separate
fitted line per group.
> - the dots with Urb=1 filled in black; and the dots with Urb=0 filled in
> white
>
> One choice is pch = c(1, 16), col = 1.
I've been back and forwards, trying to use panel function, but I
didn't> manage to do it right...
>
Here's a toy example - hopefully it will help. Only one panel, though.
df <- data.frame(g = rep(c(0, 1), each = 10),
x = rep(1:10, 2),
y = 2 + 0.8 * rep(1:10, 2) + rnorm(20),
lab = letters[1:20])
# The labels are distinct, which makes things easier - i.e., no groupwise
# dependence. If you have multiple panels, you will probably need to
# define subscripts in the panel function.
xyplot(y ~ x, data = df, groups = g, type = c('p', 'r'), pch =
c(1, 16), col
= 1,
col.line = c('red', 'black'), cex = 1.2, lwd = 1.6,
panel = function(x, y, ..., groups) {
panel.xyplot(x, y, ..., groups)
panel.text(x = df$x + 0.2, y = df$y - 0.2, lab = df$lab)
} )
Dennis
Thank you for your help in advance. Regards,>
> C.
>
> ------------------------------------
> Cristina Estima Ramalho
> PhD Candidate
> MSc in GIS
>
> Ecosystem Restoration Lab
> School of Plant Biology (M090)
> The University of Western Australia
> 35 Stirling Highway, Crawley WA 6009 Perth, Australia
> Phone: +61 (08) 6488 4655; Fax: +61 (08) 6488 7461
> www.plants.uwa.edu.au/research/ecosystem_restoration
>
>
---------------------------------------------------------------------------------
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
[[alternative HTML version deleted]]