0
我正在尝试为每个方面(按性别)基于exercise = 0或exercise = 1创建两个不同的行。第一个代码没有facet_wrap,基于性别的两行代码是不同的。第二个代码是facet_wrap,两行似乎是同一行。我怎样才能改变代码,使两条线在每个方面都有所不同?如何根据每个方面的因子创建两个不同的回归线? R,ggplot2
ggplot(cdc, aes(weight,wtdesire, color = exercise, group =
interaction(gender,exercise))) + geom_point(alpha = 1/5) +
geom_smooth(method = lm, aes(linetype=exercise))
生产:facet
然而,当我添加facet_wrap两条线每个面似乎是相同的。
ggplot(cdc, aes(weight,wtdesire, color = exercise, group =
interaction(gender,exercise))) + geom_point(alpha = 1/5) +
geom_smooth(method = lm, aes(linetype=exercise)) + facet_wrap(~gender)
生产:second
你可能需要在第二个情节只使用'组=锻炼'。 – lbusett
@LoBu我也试过,但它没有改变任何东西... –