After running a Bayesian cumulative model in brms and successfully obtaining the conditional effects plot; I’ve tuned the graph but I am unable to change the linetype of the plotted regression lines.
I can successfully change the colour of each line:
<code>the_plotsC <- plot(conditional_effects(mSEPbayesSEEN4cINT),ask = FALSE)
legend_title <- "early-life env"
<code>the_plotsC <- plot(conditional_effects(mSEPbayesSEEN4cINT),ask = FALSE)
legend_title <- "early-life env"
</code>
the_plotsC <- plot(conditional_effects(mSEPbayesSEEN4cINT),ask = FALSE)
legend_title <- "early-life env"
<code>p <- the_plotsC[[7]] +
labs(x="U003BC age (years)",y="Offspring number") +
theme(axis.line = element_line(colour = "black"),
axis.title.x = element_text(size=24),
axis.title.y = element_text(size=24, vjust=0.3),
axis.text.x=element_text(size=22,margin =margin(10,0,20,0)),
axis.text.y=element_text(size=22, margin =margin(0,10,0,20)),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
legend.title=element_text(face="bold", size=14),
legend.text=element_text(size=13),
legend.position = c(0.2, 0.9))+
scale_color_manual(legend_title,labels=c("+1SD", "Mean", "-1SD"),
values=c("gray45","gray45","gray45"))+
scale_fill_manual(legend_title,
labels=c("+1SD", "Mean", "-1SD"),
p+geom_point(data=EFrepSENseenM, aes(x=avgAGE,y=OffspringNUM), shape=21,
position = position_jitter(width = 0.3, height = 0.06),
fill="darkgray", colour="black", size=2, inherit.aes = FALSE)
<code>p <- the_plotsC[[7]] +
labs(x="U003BC age (years)",y="Offspring number") +
theme_bw() +
theme(axis.line = element_line(colour = "black"),
axis.title.x = element_text(size=24),
axis.title.y = element_text(size=24, vjust=0.3),
axis.text.x=element_text(size=22,margin =margin(10,0,20,0)),
axis.text.y=element_text(size=22, margin =margin(0,10,0,20)),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
legend.title=element_text(face="bold", size=14),
legend.text=element_text(size=13),
legend.position = c(0.2, 0.9))+
scale_color_manual(legend_title,labels=c("+1SD", "Mean", "-1SD"),
values=c("gray45","gray45","gray45"))+
scale_fill_manual(legend_title,
labels=c("+1SD", "Mean", "-1SD"),
values=cbPalette)
p+geom_point(data=EFrepSENseenM, aes(x=avgAGE,y=OffspringNUM), shape=21,
position = position_jitter(width = 0.3, height = 0.06),
fill="darkgray", colour="black", size=2, inherit.aes = FALSE)
</code>
p <- the_plotsC[[7]] +
labs(x="U003BC age (years)",y="Offspring number") +
theme_bw() +
theme(axis.line = element_line(colour = "black"),
axis.title.x = element_text(size=24),
axis.title.y = element_text(size=24, vjust=0.3),
axis.text.x=element_text(size=22,margin =margin(10,0,20,0)),
axis.text.y=element_text(size=22, margin =margin(0,10,0,20)),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
legend.title=element_text(face="bold", size=14),
legend.text=element_text(size=13),
legend.position = c(0.2, 0.9))+
scale_color_manual(legend_title,labels=c("+1SD", "Mean", "-1SD"),
values=c("gray45","gray45","gray45"))+
scale_fill_manual(legend_title,
labels=c("+1SD", "Mean", "-1SD"),
values=cbPalette)
p+geom_point(data=EFrepSENseenM, aes(x=avgAGE,y=OffspringNUM), shape=21,
position = position_jitter(width = 0.3, height = 0.06),
fill="darkgray", colour="black", size=2, inherit.aes = FALSE)
enter image description here
However I want to use line types rather than colours for each regression line. I’ve tried several ways with scale_linetype_manual unsuccessfully. For example, calling to a vector with the values for each level of the interaction plot:
<code>LINES <- c("-0.031"="solid","-0.01"="longdash","0.29"="dotted")
<code>LINES <- c("-0.031"="solid","-0.01"="longdash","0.29"="dotted")
</code>
LINES <- c("-0.031"="solid","-0.01"="longdash","0.29"="dotted")
and then using:
<code>p <- the_plotsC[[7]] +
labs(x="U003BC age (years)",y="Offspring number") +
theme(axis.line = element_line(colour = "black"),
axis.title.x = element_text(size=24),
axis.title.y = element_text(size=24, vjust=0.3),
axis.text.x=element_text(size=22,margin =margin(10,0,20,0)),
axis.text.y=element_text(size=22, margin =margin(0,10,0,20)),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
legend.title=element_text(face="bold", size=14),
legend.text=element_text(size=13),
legend.position = c(0.2, 0.5))+
scale_linetype_manual(legend_title,labels=c("+1SD", "Mean", "-1SD"),
scale_fill_manual(legend_title,
labels=c("+1SD", "Mean", "-1SD"),
p+geom_point(data=EFrepSENseenM, aes(x=avgAGE,y=OffspringNUM), shape=21,
position = position_jitter(width = 0.3, height = 0.06),
fill="darkgray", colour="black", size=2, inherit.aes = FALSE)
<code>p <- the_plotsC[[7]] +
labs(x="U003BC age (years)",y="Offspring number") +
theme_bw() +
theme(axis.line = element_line(colour = "black"),
axis.title.x = element_text(size=24),
axis.title.y = element_text(size=24, vjust=0.3),
axis.text.x=element_text(size=22,margin =margin(10,0,20,0)),
axis.text.y=element_text(size=22, margin =margin(0,10,0,20)),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
legend.title=element_text(face="bold", size=14),
legend.text=element_text(size=13),
legend.position = c(0.2, 0.5))+
scale_linetype_manual(legend_title,labels=c("+1SD", "Mean", "-1SD"),
values=LINES)+
scale_fill_manual(legend_title,
labels=c("+1SD", "Mean", "-1SD"),
values=cbPalette)
p+geom_point(data=EFrepSENseenM, aes(x=avgAGE,y=OffspringNUM), shape=21,
position = position_jitter(width = 0.3, height = 0.06),
fill="darkgray", colour="black", size=2, inherit.aes = FALSE)
</code>
p <- the_plotsC[[7]] +
labs(x="U003BC age (years)",y="Offspring number") +
theme_bw() +
theme(axis.line = element_line(colour = "black"),
axis.title.x = element_text(size=24),
axis.title.y = element_text(size=24, vjust=0.3),
axis.text.x=element_text(size=22,margin =margin(10,0,20,0)),
axis.text.y=element_text(size=22, margin =margin(0,10,0,20)),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
legend.title=element_text(face="bold", size=14),
legend.text=element_text(size=13),
legend.position = c(0.2, 0.5))+
scale_linetype_manual(legend_title,labels=c("+1SD", "Mean", "-1SD"),
values=LINES)+
scale_fill_manual(legend_title,
labels=c("+1SD", "Mean", "-1SD"),
values=cbPalette)
p+geom_point(data=EFrepSENseenM, aes(x=avgAGE,y=OffspringNUM), shape=21,
position = position_jitter(width = 0.3, height = 0.06),
fill="darkgray", colour="black", size=2, inherit.aes = FALSE)
enter image description here
or:
<code>p <- the_plotsC[[7]] +
labs(x="U003BC age (years)",y="Offspring number") +
theme(axis.line = element_line(colour = "black"),
axis.title.x = element_text(size=24),
axis.title.y = element_text(size=24, vjust=0.3),
axis.text.x=element_text(size=22,margin =margin(10,0,20,0)),
axis.text.y=element_text(size=22, margin =margin(0,10,0,20)),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
legend.title=element_text(face="bold", size=14),
legend.text=element_text(size=13),
legend.position = c(0.2, 0.5))+
scale_linetype_manual(legend_title,labels=c("+1SD", "Mean", "-1SD"),
values=c("solid","longdash","dotted))+
scale_fill_manual(legend_title,
labels=c("+1SD", "Mean", "-1SD"),
<code>p <- the_plotsC[[7]] +
labs(x="U003BC age (years)",y="Offspring number") +
theme_bw() +
theme(axis.line = element_line(colour = "black"),
axis.title.x = element_text(size=24),
axis.title.y = element_text(size=24, vjust=0.3),
axis.text.x=element_text(size=22,margin =margin(10,0,20,0)),
axis.text.y=element_text(size=22, margin =margin(0,10,0,20)),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
legend.title=element_text(face="bold", size=14),
legend.text=element_text(size=13),
legend.position = c(0.2, 0.5))+
scale_linetype_manual(legend_title,labels=c("+1SD", "Mean", "-1SD"),
values=c("solid","longdash","dotted))+
scale_fill_manual(legend_title,
labels=c("+1SD", "Mean", "-1SD"),
values=cbPalette)
</code>
p <- the_plotsC[[7]] +
labs(x="U003BC age (years)",y="Offspring number") +
theme_bw() +
theme(axis.line = element_line(colour = "black"),
axis.title.x = element_text(size=24),
axis.title.y = element_text(size=24, vjust=0.3),
axis.text.x=element_text(size=22,margin =margin(10,0,20,0)),
axis.text.y=element_text(size=22, margin =margin(0,10,0,20)),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
legend.title=element_text(face="bold", size=14),
legend.text=element_text(size=13),
legend.position = c(0.2, 0.5))+
scale_linetype_manual(legend_title,labels=c("+1SD", "Mean", "-1SD"),
values=c("solid","longdash","dotted))+
scale_fill_manual(legend_title,
labels=c("+1SD", "Mean", "-1SD"),
values=cbPalette)
but none of them work…
Any help will be greatly appreciated. I realise I haven’t shared any df because the_plotsC is in fact a list.