I have a data table similar to the following:
I am trying to plot points (categorical variable “Data”) corresponding to each patient per week (some longitudinal data are missing) but I need to increase a bit the distance between points of categorical variable “Data” in the horizontal axis. I am trying with the following code:
df=read.delim("/Volumes/test.txt",header=TRUE,sep="\t")
df=df[order(df$ID),]
df$Timepoint<-factor(df$Timepoint,levels=c("w0","w1","w6","w7","w8","w10"))
df$Phase<-factor(df$Phase,levels=c("pre_treat","treat","post_treat"))
ggplot(df,aes(x=Timepoint,y=ID,shape=Data))+
geom_point(aes(color=Data,shape=Data),size=3.5, position = position_jitter(w = 0.1, h = 0))+
facet_wrap(~Phase,scales="free_x")+
scale_shape_manual(values=c(16,0,17))+
scale_colour_manual(values=c("black","black","gray60"))+
theme_bw()+ylab("ID")+
theme(axis.text.x = element_text(angle = 45, hjust = 1))
The problem I am encountering is that points are too close and the order of each symbol seems randomly represented.
I tried with both position_jitter and position_dodge but I still obtain diagonal-oriented or overlapping point. Thank you very much for your help!