Multiple Vector Plot + line colours and marking

Hi there, I am trying to plot the data below, but I am struggling to figure out how to plot multiple vectors with different lengths. Since they are different lengths, I wasn't able to use a data frame and instead, I have tried to put it in list form and based on other forums I tried to use mapply but I am now struggling to figure out how to manually (not arbitrarily) set individual colors for each line in the plot and to put dots on the lines where they correspond to a data point (for example a = 0.95). Any advice on how to maybe more efficiently but also more intuitively solve this problem is welcome.


xstar=0.85
x1 =  c(0.8262858, 0.9102857, 0.9032932, 0.8994474, 0.8994474)
x2 =  c(0.8151768, 0.9053250, 0.8994474, 0.8975376, 0.8975376)
a =  c(0.3000000, 0.8151768, 0.8151768, 0.8151768, 0.8151768, 0.8151768)
b = c(0.9500000, 0.9500000, 0.9102857, 0.8994474, 0.8994474, 0.8994474)


biaspl = list(x1 = c(x1), x2 = c(x2), a = c(a), b = c(b))


plot(unlist(biaspl), type = "l", main = "Evolution of Legal Threshold and Effort Levels", xlim = c(1,length(period)), ylim = (0:1),xlab = expression("Time Period (t)"),ylab = expression("Threshold/Effort Level"))
  axis(side=2,seq(0,1,0.1))
  axis(side=1,seq(0,5,1))
  abline(h = xstar, col=("yellow"), lwd=2, lty=1)
  mapply(lines, biaspl, col="blue")
  legend("bottomright", c("x1","x2","a","b"), fill = c("blue","red","green","green"))

1 Like