You just want to connect the paired samples, as in a bi-partite plot? I think that these plots have a different name each time one asks a different person.
This code worked for me. Note that I had to melt the data-frame first such that the paired observations were in a single column:
#melt dataframe
mydf<- melt(mydf, id.vars="sampleID", variable.name="vitD", value.name="value")
#plotting in ggplot2
graph <- ggplot(data=mydf, aes(x=vitD, y=value, group=sampleID)) +
geom_line(size=0.3) +
geom_point(size=2.5, shape=21, fill=colour, colour='black') +
xlab("") + ylab("Vitamin D (ng/ml)") +
ylim(0, 100) +
#Modify various aspects of the plot text and legend
theme(
legend.position="none",
legend.background=element_rect(),
plot.title=element_text(angle=0, size=10, face="bold", vjust=1),
axis.text.x=element_text(angle=0, size=10, face="bold", vjust=0.5),
axis.text.y=element_text(angle=0, size=10, vjust=0.5),
axis.title=element_text(size=10),
#Legend
legend.key=element_blank(), #removes the border
legend.key.size=unit(1, "cm"), #Sets overall area/size of the legend
legend.text=element_text(size=8), #Text size
title=element_text(size=8)) + #Title text size
ggtitle(title) +
geom_hline(yintercept=30, colour="red", size=1.25, linetype="solid")
I get an error message as "Error: Aesthetics must be either length 1 or the same as the data (858): x, y, group"
Please paste a sample of your data. Also, can you add this as a comment to my answer (below)? Use the
ADD COMMENT
button. Thanks!