Hi,
I am new to lattice graphics and have the following question. I have a
dataframe d2:
cat PointsInTime MeanScore
1 Parent Intake 26.25000
2 Youth Intake 9.75000
3 Worker Intake 20.63636
4 Parent Discharge 24.00000
5 Youth Discharge 15.60000
6 Worker Discharge 23.90909
and to produce a plot I am using the following code
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")))
However, I want to data labels to the plot and think I need to use the panel
function, but am not sure how to proceed. Please help
Thanks
Chandra
--
Chandrasekhar Ganduri
320 West Union St, APT # 105
Athens, OH - 45701
Ph: 740-274-9170
[[alternative HTML version deleted]]
> 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.
Thanks for the reply..though I am trying to still work around the problem of overlapping labels -- Chandrasekhar Ganduri 320 West Union St, APT # 105 Athens, OH - 45701 Ph: 740-274-9170 [[alternative HTML version deleted]]
Hi,
I got something to work...thanks for the help.
Herez the code -
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"),
panel=function(x, y,...) {
panel.xyplot(x, y,...)
panel.text(d2$PointsInTime, d2$MeanScore,
labels=round(d2$MeanScore, digits=2), pos=4, offset=0.8)
}
)
This takes care of the xyplot maintaining the lines and grouping, but not
overlapping labels for which I could not find a solution
Chandra
--
Chandrasekhar Ganduri
320 West Union St, APT # 105
Athens, OH - 45701
Ph: 740-274-9170
[[alternative HTML version deleted]]