我使用以下命令创建我的图:
AfterLatency <- ggplot(
After,
aes(
x = After$X7.Days.Time.in.Blank,
y = After$X7.Days.Latency.to.Leave,
shape = factor(Treatment),
color = factor(Treatment)
)
) +
geom_point() +
geom_smooth(method = "lm", se = FALSE) +
xlab("Time in Blank (s)") +
ylab("Latency to leave (s)")
我试过了:AfterLatency + scale_linetype_manual("Treatment", values=c("Control"=2, "Sertraline"=4))
并尝试在geom_smooth中包含linetype
命令,但都没有工作。
答案 0 :(得分:0)
尝试添加linetype
作为geom_smooth
的审美。
geom_smooth(method = 'lm', se = FALSE, aes(linetype = Treatment))
此外,不需要After$
。如果在geoms中使用其他映射,这很有用。
答案 1 :(得分:0)
首先尝试使用lty
作为aes
中ggplot
的参数开始:
AfterLatency <- ggplot(
After,
aes(
x = After$X7.Days.Time.in.Blank,
y = After$X7.Days.Latency.to.Leave,
shape = factor(Treatment),
color = factor(Treatment),
lty=factor(Treatment)
)
)