我有一个类似于以下内容的数据表:我正在尝试绘制每周对应每个患者的点(分类变量“数据”)(缺少一些纵向数据),但是我需要在水平轴上稍微增加分类变量“数据”的点之间的距离。我正在尝试以下代码:
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))
我同时尝试了position_jitter和position_dodge,但仍然获得了对角线指向或重叠的点。非常感谢您的帮助!
geom_point( ..., fill=alpha("red",0.2), color="black", shape=21 )
应与形状21-25一起使用