Paired line between two observations in stripchart ?
1
0
Entering edit mode
6.0 years ago
Björn ▴ 110

I used following command stripchart(normcounts["831",]~group$Groups1,vertical=TRUE,las=2,cex.axis=0.8,pch=16,col=1:5,method="jitter", ylab= "normalized counts", xlab="Patient groups", main="Main",cex.main=0.8) and got following figure ![enter image description here][1] [1]: https://ibb.co/mt2aHS

My questions: 1. how to show line between paired sample ?

+   geom_line(aes(group=group$Groups1))+
+   geom_point()

But did not work.

  1. how to remove C and CF so that I have chart only with B AND BF

Thanks

stripchart ggplot geom_line rstudio • 4.7k views
ADD COMMENT
0
Entering edit mode

I get an error message as "Error: Aesthetics must be either length 1 or the same as the data (858): x, y, group"

ADD REPLY
0
Entering edit mode

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!

ADD REPLY
0
Entering edit mode
6.0 years ago

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")

f

ADD COMMENT

Login before adding your answer.

Traffic: 2530 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6