Second plot series send to background

Is it possible to send a second plot (e.g. a vertical line) to the background? I know, if I drew the vertical line first, I would get what I want. However, then I have to provide axis scales in order to get a nice plot.

MWE:

using Plots
plot(rand(4))
vline!([2.])

I don’t have a solution, but I would say that this (the fact that the default axis limits depend on the series order) is a bug and you should file an issue with Plots.

Why exactly providing axis scales is a problem? Maybe you could specify a little bit further the issue?

1 Like

One hacky way around would be to just plot whatever you want to plot second first with alpha = 0.0, label = "") to automatically get the axis limits, then vline!(), then plot() again

Thanks for the hack! :slight_smile: