i have this data and plot
mydata <- data.frame(a=c(1:5),b=c(6:10),c=c(11:15),e=c(16:20))
plot <- stripchart(mydata, method="jitter", vertical=T,main='plot',pch=19)
I would like to subset the x axis into two labels named 'a+b' and 'c+d' labels
Thanks in advance
In your case you can simply use mtext
on side 1:
mydata <- data.frame(a=c(1:5),b=c(6:10),c=c(11:15),d=c(16:20))
plot <- stripchart(mydata, method="jitter", vertical=T,main='plot',pch=19)
mtext(c('a+b','c+d'),side=1,line=3,at=c(1.5,3.5))
Argument line
is to set up the vertical position and at
the position on the x-axis.
Edit: To add a distance between the two groups, you can do like this (there may be a cleaner way to do that but that's the only one I can think of from the top of my head):
mydata <- data.frame(a=c(1:5),b=c(6:10),c=c(11:15),d=c(16:20))
plot <- stripchart(mydata, method="jitter", vertical=T, main='plot',pch=19,
at=c(1,2,4,5),xlim=c(0,6))
mtext(c('a+b','c+d'),1,line=3,at=c(1.5,4.5))
Argument at
of stripchart
is the one to fiddle with, but you then have to modify the plot limits (xlim
) and the x-value at which you write the axis label (in mtext
).