[R] Adding data labels to Lattice plots

David Hewitt dhewitt at vims.edu
Thu Dec 13 01:57:53 CET 2007




> I am new to lattice graphics...
> 

Me too, for the most part, so this might not be great advice.



> print(xyplot(MeanScore ~ PointsInTime, d2, groups = cat, type = 'o',
>         xlab = "Points in Time", ylab = "Mean Score", aspect = 0.7,
>         auto.key = list(points = TRUE, lines = TRUE, space = "right")))
> 

This will get the labels on the points, but you need a way to avoid
overlapping labels. And the xyplot is not maintaining the lines and grouping
in this new arrangement.

panel1 = function(x, y) {
     panel.xyplot(x, y)
     panel.text(PointsInTime, MeanScore,
          labels=round(MeanScore, digits=2), pos=2, offset=0.8)
     }

xyplot(MeanScore ~ PointsInTime, data=stuff, groups=cat, type='o',
        xlab = "Points in Time", ylab = "Mean Score", aspect = 0.7,
        auto.key = list(points = TRUE, lines = TRUE, space = "right"),
        panel=panel1)

-----
David Hewitt
Virginia Institute of Marine Science
http://www.vims.edu/fish/students/dhewitt/
-- 
View this message in context: http://www.nabble.com/Adding-data-labels-to-Lattice-plots-tp14297921p14307638.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list