This is happening because TEMP
has two levels whereas PARENT
has three. ggplot
will dodge based on how many levels you have. Since you have two boxplots dodge will line up properly when your points have two levels. If you had three boxplots, then PARENT
dodge points would line up fine. Here is a workaround using group
:
geom_point( aes(group=factor(TEMP), color=factor(PARENT)), position=position_dodge(width=0.75))
This works because by default color
will assign groups if groups are not otherwise defined. Since here we actively specify groups, those prevail and dodge dodges based on the explicit groups rather than the color implied groups.