2

I an trying to plot 6 groups, in which 3 has a good amount of counts (ranging from 20 to 400) and the rest 3 have very small counts (1 to 9). I want to plot the distribution of a continuous variable within each of these 6 groups and be very honest in the plot about the dramatically different sizes of the groups. I am thinking about generating violin plot for the 3 groups with larger counts to show both the median and the dispersion, and for the low-count groups, plot stripchart to show individual data points.

Could anyone kindly help me find a way to do such a hybrid plot? Other plot suggestions are also welcome.

HueSX
  • 185
  • 9

1 Answers1

4

Here's a basic one done in R:

# make some data
y1=rnorm(1,10);y2=rnorm(5,9);y3=rnorm(9,10.5)
y4=rnorm(20,9.5);y5=rnorm(90,11);y6=rnorm(400,10.25,2)


# do the plot
plot(y=rep(6,length(y6)),x=y6,ylim=c(0,7),
  xlim=c(min(y1,y2,y3,y4,y5,y6),max(y1,y2,y3,y4,y5,y6)),
  type="n",xlab="",ylab="",yaxt="n")
stripchart(x=list(y1=y1,y2=y2,y3=y3),at=c(1,2,3),add=TRUE,pch=1)
vioplot(y4,y5,y6,at=c(4,5,6),add=TRUE,horizontal=TRUE)
axis(2,at=1:6,labels=c("y1","y2","y3","y4","y5","y6"))

enter image description here

Glen_b
  • 257,508
  • 32
  • 553
  • 939