Reputation: 25
Why do the following codes generate different plots? What's the difference between xyplot() and dotplot()?
library(lme4)
library(lattice)
str(Dyestuff)
xyplot(reorder(Batch,Yield)~Yield,Dyestuff,ylab = "Batch", jitter.y = TRUE, pch = 21, aspect = 0.32,
xlab = "Yield of dyestuff (grams of standard color)",
type = c("p", "a","g"))
dotplot(reorder(Batch, Yield) ~ Yield, Dyestuff,
ylab = "Batch", jitter.y = TRUE, pch = 21, aspect = 0.32,
xlab = "Yield of dyestuff (grams of standard color)",
type = c("p", "a"))
Upvotes: 1
Views: 65
Reputation: 50718
I assume your question refers to the fact that the lines (not points) shown in xyplot
and dotplot
are different.
This is perhaps not a full answer, but the key to your answer seems is in the documentation to panel.xyplot
, panel.dotplot
and panel.average
.
Specifying type = "a"
has the effect of calling panel.average
.
It seems that xyplot
and dotplot
average the data differently. While xyplot
averages Batch
values per Yield
(which is not very meaningful here since Batch
is a categorical factor
variable), dotplot
averages Yield
values per Batch
.
Upvotes: 1