How to overlay a boxplot with a dot plot in R

38 Views Asked by At

I created a boxplot for my data but want to overlay it with a dotplot of the same data but im not sure how to modify my code to do this. This is my current code and the graph I produced:

data_GAM1<-subset(data,Gene=="GAM1")

boxplot(logRE ~ Sort, data = data_GAM1, ylab = 'Log RE of Gam1', xlab = 'Condition', col = rep(c('darkgoldenrod2', 'cadetblue3'), each = 4), xaxt = "n")

axis(1, at = 1:4, labels = c("Co","dve","Lac","REL2"))
axis(1, at = 5:8, labels = c("Co","dve","Lac","REL2"))

legend("topright", c("Anterior", "Posterior"), cex=1,fill = c("darkgoldenrod2", "cadetblue3"), box.lty=0)

Boxplot

enter image description here

I would also like to make the points of the dot plot a different colour to the boxes.

0

There are 0 best solutions below