For the following code is there a way to make the jitter all line up
horizontally, instead of them being just randomly spread around a value. So for
ex if there are multiple values at 63 for genotype wt then all the values should
be plotted on the same y value of 63 but spaced apart by a certain factor or
noise..
library(lattice);
dataFrame <- as.data.frame(t(structure(c(
64,'wt',
62,'wt',
66,'wt',
65,'wt',
60,'wt',
61,'wt',
65,'wt',
66,'wt',
65,'wt',
63,'wt',
67,'wt',
65,'wt',
62,'wt',
65,'wt',
68,'wt',
65,'wt',
63,'wt',
65,'wt',
62,'wt',
65,'wt',
66,'wt',
62,'wt',
65,'wt',
65,'wt',
66,'wt',
65,'wt',
62,'wt',
65,'wt',
66,'wt',
65,'wt',
61,'wt',
65,'wt',
66,'wt',
65,'wt',
62,'wt',
63,'het',
67,'het',
60,'het',
67,'het',
66,'het',
62,'het',
65,'het',
62,'het',
61,'het',
62,'het',
66,'het',
60,'het',
65,'het',
65,'het',
61,'het',
64,'het',
68,'het',
64,'het',
63,'het',
62,'het',
64,'het',
62,'het',
64,'het',
65,'het',
60,'het',
65,'het',
70,'het',
63,'het',
67,'het',
66,'het',
65,'hom',
62,'hom',
68,'hom',
67,'hom',
67,'hom',
63,'hom',
67,'hom',
66,'hom',
63,'hom',
72,'hom',
62,'hom',
61,'hom',
66,'hom',
64,'hom',
60,'hom',
61,'hom',
66,'hom',
66,'hom',
66,'hom',
62,'hom',
70,'hom',
65,'hom',
64,'hom',
63,'hom',
65,'hom',
69,'hom',
61,'hom',
66,'hom',
65,'hom',
61,'hom',
63,'hom',
64,'hom',
67,'hom'), .Dim=c(2,98))));
colnames(dataFrame) <- c('marbles_buried', 'genotype');
dataFrame[c("marbles_buried")] <-
lapply(dataFrame[c("marbles_buried")], function(x)
as.numeric(levels(x)[x]));
trellis.par.set(theme = col.whitebg());
stripplot(jitter(marbles_buried) ~ genotype, data = dataFrame, aspect = 1,
jitter = TRUE, xlab='Genotype', ylab = "Marbles Buried",
main='MBA WTs Vs HOMs');
Thanks,
Sandeep Kumar Ghosh
Lexicon Genetics, Inc.,
8800 Technology Forest,
The Woodlands, TX 77380
(281) 863-3479
Internal Extension - 3479
[[alternative HTML version deleted]]
Ghosh, Sandeep wrote:> For the following code is there a way to make the jitter all line up horizontally, instead of them being just randomly spread around a value. So for ex if there are multiple values at 63 for genotype wt then all the values should be plotted on the same y value of 63 but spaced apart by a certain factor or noise.. ><snip>>Yes, remove the jitter function call: stripplot(marbles_buried ~ genotype, data = dataFrame, aspect = 1, jitter = TRUE, xlab='Genotype', ylab = "Marbles Buried", main='MBA WTs Vs HOMs') --sundar
On Thursday 30 June 2005 11:40, Ghosh, Sandeep wrote:> Thanks for the prompt reply. I need some more help. I want the datapoints > for each group to show up in a different color, like all wt data points to > be green, het to be blue and hom to be red. Also I need the median point of > all the data points plotted as well by a short line as shown in attachment.stripchart takes you almost all the way there: with(dataFrame, stripchart(marbles_buried ~ genotype, vert = TRUE, method = "jitter", col = c('blue', 'red', 'green'))) meds <- as.vector(with(dataFrame, by(marbles_buried, genotype, median))) segments((1:3)-0.25, meds, (1:3)+0.25, meds, col = c('blue', 'red', 'green')) Deepayan
Another question, in stripchart is there a way to draw a legends. I need legends that gives the mice count for each genotype wt/het/hom, something like the xyplot plot support for key/auto.key. -Sandeep -----Original Message----- From: Deepayan Sarkar [mailto:deepayan at stat.wisc.edu] Sent: Thursday, June 30, 2005 12:04 PM To: Ghosh, Sandeep Cc: Sundar Dorai-Raj; r-help at stat.math.ethz.ch Subject: Re: [R] Help with stripplot On Thursday 30 June 2005 11:40, Ghosh, Sandeep wrote:> Thanks for the prompt reply. I need some more help. I want the datapoints > for each group to show up in a different color, like all wt data points to > be green, het to be blue and hom to be red. Also I need the median point of > all the data points plotted as well by a short line as shown in attachment.stripchart takes you almost all the way there: with(dataFrame, stripchart(marbles_buried ~ genotype, vert = TRUE, method = "jitter", col = c('blue', 'red', 'green'))) meds <- as.vector(with(dataFrame, by(marbles_buried, genotype, median))) segments((1:3)-0.25, meds, (1:3)+0.25, meds, col = c('blue', 'red', 'green')) Deepayan