Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add boxplots to scatterplot with jitter

Tags:

plot

r

lattice

I am using following commands to produce a scatterplot with jitter:

ddf = data.frame(NUMS = rnorm(500), GRP = sample(LETTERS[1:5],500,replace=T)) library(lattice) stripplot(NUMS~GRP,data=ddf, jitter.data=T) 

I want to add boxplots over these points (one for every group). I tried searching but I am not able to find code plotting all points (and not just outliers) and with jitter. How can I solve this. Thanks for your help.

like image 311
rnso Avatar asked May 15 '14 10:05

rnso


People also ask

Is a jitter plot a scatter plot?

A jitter plot represents data points in the form of single dots, in a similar manner to a scatter plot. The difference is that the jitter plot helps visualize the relationship between a measurement variable and a categorical variable.

What is boxplot jitter?

The use of jitter is a great technique in dot plots, box plots with dots, and scatter plots. Jitter is a random value (or for our purposes pseudo-random) that is assigned to the dots to separate them so that they aren't plotted directly on top of each other.


1 Answers

Here's one way using base graphics.

boxplot(NUMS ~ GRP, data = ddf, lwd = 2, ylab = 'NUMS') stripchart(NUMS ~ GRP, vertical = TRUE, data = ddf,      method = "jitter", add = TRUE, pch = 20, col = 'blue') 

enter image description here

like image 147
Rich Scriven Avatar answered Sep 18 '22 22:09

Rich Scriven