Reputation: 119
I am using lattice with the following code:
stripplot(locs~factor(rep(1,length(locs)))|dataset,
col=locs.col,
pch=19,cex=0.7,
jitter.data=T,factor=rep(rnorm(length(locs))),
amount=abs(rep(rnorm(length(locs))))*0.05 )
However, this seems to be plotting wrong compared to what I would expect. If I plot by the factors in dataset individually, the second and third plots plotted separately differ with respect to the color from what I get in the combined lattice plots.
For e.g. the second plot individually:
stripplot(locs[101:200]~factor(rep(1,length(locs[101:200])))|dataset[101:200],
col=locs.col[101:200],
pch=19,cex=0.7,
jitter.data=T,factor=rep(rnorm(length(locs[101:200]))),
amount=abs(rep(rnorm(length(locs[101:200]))))*0.05 )
doesn't give the same as what I get in the second panel's plot.
I've tried varying the order of the dataset values but this doesn't work.
I've put the data below.
locs=c(44L, 71L, 93L, 69L, 67L, 58L, 107L, 57L, 66L, 54L, 73L, 59L,
43L, 65L, 64L, 60L, 45L, 83L, 79L, 85L, 83L, 73L, 66L, 64L, 43L,
84L, 39L, 43L, 130L, 80L, 57L, 91L, 62L, 40L, 60L, 65L, 97L,
47L, 83L, 44L, 120L, 95L, 44L, 51L, 68L, 44L, 74L, 72L, 55L,
68L, 67L, 63L, 52L, 54L, 86L, 67L, 67L, 47L, 54L, 53L, 76L, 38L,
67L, 66L, 71L, 52L, 69L, 46L, 71L, 64L, 43L, 56L, 69L, 69L, 94L,
45L, 41L, 67L, 43L, 73L, 81L, 51L, 43L, 94L, 75L, 45L, 52L, 42L,
93L, 44L, 44L, 80L, 45L, 68L, 41L, 101L, 66L, 64L, 45L, 52L,
51L, 44L, 48L, 80L, 50L, 55L, 48L, 80L, 88L, 47L, 90L, 72L, 43L,
54L, 96L, 54L, 45L, 76L, 59L, 45L, 75L, 53L, 46L, 95L, 43L, 112L,
44L, 47L, 46L, 44L, 105L, 91L, 72L, 106L, 89L, 123L, 49L, 46L,
70L, 81L, 41L, 100L, 85L, 48L, 54L, 85L, 46L, 140L, 94L, 47L,
80L, 106L, 77L, 59L, 46L, 90L, 49L, 91L, 41L, 50L, 37L, 46L,
47L, 81L, 33L, 60L, 49L, 49L, 47L, 47L, 59L, 48L, 67L, 45L, 77L,
102L, 96L, 146L, 86L, 44L, 124L, 113L, 54L, 93L, 53L, 48L, 114L,
72L, 47L, 46L, 56L, 86L, 89L, 49L, 47L, 45L, 46L, 55L, 101L,
76L, 91L, 46L, 128L, 117L, 123L, 112L, 68L, 68L, 40L, 53L, 61L,
42L, 43L, 66L, 34L, 50L, 43L, 88L, 111L, 93L, 39L, 120L, 33L,
52L, 86L, 90L, 38L, 78L, 94L, 89L, 129L, 49L, 107L, 79L, 88L,
67L, 42L, 34L, 119L, 43L, 65L, 90L, 45L, 95L, 94L, 74L, 112L,
47L)
dataset=structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("T1",
"H2", "V6"), class = "factor")
locs.col=c("darkblue", "yellow", "red", "yellow", "yellow", "yellow",
"red", "yellow", "yellow", "yellow", "yellow", "yellow",
"darkblue", "yellow", "yellow", "yellow", "darkblue",
"yellow", "yellow", "yellow", "yellow", "red", "yellow",
"yellow", "darkblue", "yellow", "darkblue", "darkblue",
"red", "red", "yellow", "yellow", "yellow", "darkblue",
"yellow", "yellow", "red", "yellow", "red", "darkblue",
"red", "red", "darkblue", "darkblue", "yellow", "darkblue",
"red", "yellow", "yellow", "yellow", "yellow", "yellow",
"yellow", "yellow", "red", "yellow", "yellow", "yellow",
"yellow", "yellow", "yellow", "darkblue", "yellow",
"yellow", "yellow", "yellow", "yellow", "yellow",
"yellow", "yellow", "darkblue", "yellow", "yellow",
"yellow", "yellow", "darkblue", "darkblue", "yellow",
"darkblue", "yellow", "yellow", "darkblue", "darkblue",
"red", "yellow", "darkblue", "yellow", "darkblue", "yellow",
"darkblue", "darkblue", "yellow", "darkblue", "red", "darkblue",
"red", "yellow", "red", "darkblue", "darkblue", "darkblue",
"darkblue", "darkblue", "yellow", "darkblue", "darkblue",
"darkblue", "yellow", "yellow", "darkblue", "yellow",
"yellow", "darkblue", "darkblue", "red", "darkblue", "darkblue",
"yellow", "yellow", "darkblue", "yellow", "darkblue",
"darkblue", "yellow", "darkblue", "red", "darkblue", "darkblue",
"darkblue", "darkblue", "yellow", "red", "yellow", "red",
"yellow", "red", "darkblue", "darkblue", "yellow", "yellow",
"darkblue", "yellow", "yellow", "darkblue", "darkblue",
"yellow", "darkblue", "red", "yellow", "darkblue", "yellow",
"red", "yellow", "darkblue", "darkblue", "yellow", "darkblue",
"yellow", "darkblue", "yellow", "darkblue", "darkblue",
"darkblue", "yellow", "darkblue", "yellow", "darkblue",
"darkblue", "darkblue", "darkblue", "darkblue", "darkblue", "yellow",
"darkblue", "yellow", "yellow", "yellow", "red", "yellow",
"darkblue", "red", "red", "darkblue", "yellow", "darkblue",
"darkblue", "yellow", "yellow", "darkblue", "darkblue",
"darkblue", "yellow", "yellow", "darkblue", "darkblue",
"darkblue", "darkblue", "darkblue", "yellow", "yellow",
"yellow", "darkblue", "red", "red", "red", "red", "yellow",
"yellow", "darkblue", "yellow", "yellow", "darkblue",
"darkblue", "yellow", "darkblue", "darkblue", "darkblue",
"yellow", "red", "yellow", "darkblue", "red", "darkblue",
"darkblue", "yellow", "yellow", "darkblue", "yellow",
"yellow", "yellow", "red", "darkblue", "red", "yellow",
"red", "darkblue", "darkblue", "darkblue", "yellow", "darkblue",
"darkblue", "red", "darkblue", "yellow", "yellow", "yellow",
"yellow", "darkblue")
NB: Since I lost my account details to thie question I posted here previously, I'm reposting this question, admins please feel free to merge question etc.
Upvotes: 1
Views: 510
Reputation: 119
So I needed to change col
to groups
stripplot(locs~factor(rep(1,length(locs)))|dataset,
groups=locs.col,
pch=19,cex=0.7,
jitter.data=T,factor=rep(rnorm(length(locs))),
amount=abs(rep(rnorm(length(locs))))*0.05 )
Upvotes: 1