Skip to content
Prev 131964 / 398506 Next

Adding data labels to Lattice plots

Me too, for the most part, so this might not be great advice.
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/