I have created a series of plots used in Shiny, that displays a curve, then adds a pair of lines to show x and y axis intercepts. This works great. The lines are red and dashed.
I am trying to add a second set of lines showing a different x and y intercept. These are supposed to be green and solid.
When I add the second set of lines, things get screwed up. The second set becomes red and solid, the first set becomes green and dashed.
Any ideas on what is happening?
qplot(y()$TrueNC,y()$AOQ,data=y(),
ylab="Average Outgoing Quality",
xlab="Probability of Nonconformance",
main="Average Outgoing Quality",
xlim=c(0.0,1.0),
ylim=c(initLimit(),plotYLimit()),
geom="line"
)+geom_segment(
aes(
x = probvec2()[2]+probvec2()[4],
y = 0,
xend = probvec2()[2]+probvec2()[4],
yend = round(max(y()$AOQ),4)+0.01,
colour="red"),
linetype=2
)+geom_segment(
aes(
x = 0,
y = approx(y()$TrueNC,y()$AOQ,xout=probvec2()[2]+probvec2()[4],method="linear")$y,
xend = probvec2()[2]+probvec2()[4]+0.03,
yend = approx(y()$TrueNC,y()$AOQ,xout=probvec2()[2]+probvec2()[4],method="linear")$y,
colour="red"),
linetype=2
)+geom_segment(
aes(
x = approx(y()$AOQ,y()$TrueNC,xout=input$ecr_t,method="linear")$y,
y = 0,
xend = approx(y()$AOQ,y()$TrueNC,xout=input$ecr_t,method="linear")$y,
yend = round(max(y()$AOQ),4)+0.01,
colour="green"),
linetype=1
)+geom_segment(
aes(
x = 0,
y = approx(y()$TrueNC,y()$AOQ,xout=probvec2()[2]+probvec2()[4],method="linear")$y,
xend = approx(y()$AOQ,y()$TrueNC,xout=input$ecr_t,method="linear")$y+0.03,
yend = approx(y()$TrueNC,y()$AOQ,xout=probvec2()[2]+probvec2()[4],method="linear")$y,
colour="green"),
linetype=1
)+theme(legend.position = "none")
})