Getting x and y are different lengths in legend creations

It has been years since I have used base graphics but I think you need something like:

legend("topleft", legend=c("Mean Line (-----)", "95% CB",
"95% Prediction", "WH"), col=c("red1", "deepskyblue", "springgreen4"  ))

Otherwise can you supplyxus with more complete code and some sample data?

FAQ: How to do a minimal reproducible example ( reprex ) for beginners