此问题在此处已有答案:
Is it possible to jitter two ggplot geoms in the same way?(4个答案)
How to combine position_dodge() and geom_line() with overlapping groupings?(2个答案)
using position_dodge with geom_line(1个答案)
昨天关门了。
此帖子已于昨天编辑并提交审核,未能重新打开帖子:
原始关闭原因未解决
使用position_dodge时,几何点(点)和几何线(线)在ggplot 2中的位置不成对
下面是我的代码:
ggplot(data = datae.19.26, aes(x=as.factor(assay.tem), y=change.fitness ))+
geom_point(aes(group= as.factor(evolution.tem)), position = position_dodge(width = 0.3))+
xlab(expression(paste("Assasy environment"))) +
ylab(expression(paste("Change in fitness"))) +
labs(shape=expression("Evolution\nenvironment", degree~"C"))+
geom_line(aes(linetype=as.factor(evolution.tem),group= tag),position = position_dodge(width = 0.3))+
theme_classic()
)
这是我的数据
标签=块+演化.tem +组
我的数据(用于测试):
assay.tem <- c(19,19,19,19,19,19,19,19,26,26,26,26,26,26,26,26)
evolution.tem <- c(19,19,26,26,19,19,26,26,19,19,26,26,19,19,26,26)
tag <- c("A19a","A19b","A26a","A26b","B19a","B19b","B26a","B26b","A19a","A19b","A26a","A26b","B19a","B19b","B26a","B26b")
change.fitness <- c(0.148000525,0.422677262,0.360426885,0.336559874,0.611094594,0.515070536,0.173537012,0.325389861,0.441893408,0.689221781,0.573697751,0.564322921,0.709060167,0.911127005,0.613946604,0.572489802)
datae.test <- data.frame (assay.tem,evolution.tem,tag,change.fitness)
我猜默认的点的位置躲避是'as.factor(evolution.tem)',而线的位置躲避是'tag',但是我该怎么解决这个问题呢?
(note线和点的组不相同!与using position_dodge with geom_line不同)
1条答案
按热度按时间lfapxunr1#
试试这个:
我们不需要
position_dodge
:基本上:这就是答案:
可以扩展的基本方法:由于你不提供所有的数据,我过滤了相关对:
数据: