Vlines ymin, ymax

Are your sure you are looking for matplotlib’s vlines equivalent? Because that’s exactly Plots.jl’s vline, but that will not give you the difference between y and yhat AFAIK.

(Side note: your MWE does not run because a and b are not defined.)


Edit: OK I think I know what you mean. You want to plot segments from y to yhat. You can do that by manually plotting each segment. One way is put all the coordinates in a vector and separate the segments with NaNs. E.g.,

x2 = repeat(x, inner=3)
y2 = reduce(vcat, [y, yhat, NaN] for (y, yhat) in zip(y, yhat))
plot!(x2, y2)

2 Likes