[R] Specifying data point locations on x-axis using boxplot() and points()

Kota Hattori kota.hattori at canterbury.ac.nz
Thu Aug 18 06:03:27 CEST 2011


Hi all,

I would like to ask a question with regard to R graphics. I am currently
trying to add data points in boxplots using points(). In my script, I add
up boxplots three times using add=TRUE. I use points() every time I add
boxplots, and I see data points. However, I see all data points are clustered
at three specific points on x-axis; the locations of the data points
are not overlapping with intended boxplots. This is because I use
"at" in boxplot(). Is there any way that I can specify the locations of the
data points on x-axis? It would be great if there is something like
"at" in points(). Thank you for your help.

Cheers,
Kota

The following is my script.


boxplot(F2.E$D.value ~ F2.E$consonant,
	main = "F2",
	ylim = c(-4,10),
	ylab = "Sensitivity (d')",
	xlab = "Discrimination Type",
	names = (c("E","E","E")),
	col = "light grey",
	border = "grey",
	boxwex = 0.2,
	at = 1:3 - 0.27
	)

points(jitter(rep(1:3, each = 8),0.1),
		unlist(split(F2.E$D.value,F2.E$consonant)),		
		cex = 0.5, 
		pch = 16)


boxplot(F2.J.pre$D.value ~ F2.J.pre$consonant,
	add = TRUE,
	col = "light grey",
	border = "grey",
	names = (c("J Pre","J Pre","J pre")),
	boxwex = 0.2,
	at = 1:3 - 0)

points(jitter(rep(1:3, each = 28), 0.1),
		unlist(split(F2.J.pre$D.value,F2.J.pre$consonant)),		
		cex = 0.5,
		col = "blue",
		pch = 16)

boxplot(F2.J.post$D.value ~ F2.J.post$consonant,
	add = TRUE,
	col = "light grey",
	border = "grey",
	names = (c("J Post","J Post","J Post")),
	boxwex = 0.2,
	at = 1:3 + 0.27)

points(jitter(rep(1:3, each = 28), 0.1),
		unlist(split(F2.J.post$D.value,F2.J.post$consonant)),		
		cex = 0.5,
		col = "green", 
		pch = 16)

This email may be confidential and subject to legal privilege, it may
not reflect the views of the University of Canterbury, and it is not
guaranteed to be virus free. If you are not an intended recipient,
please notify the sender immediately and erase all copies of the message
and any attachments.

Please refer to http://www.canterbury.ac.nz/emaildisclaimer for more
information.



More information about the R-help mailing list