Vspan vertical scale wrong when using dates as x axis

I am trying to use vspan to highlight specific periods in a plot with dates as x axis. It seems that vspan changes the y axis units to dates also (which is wrong).


# Show vspan problem with date abscissaes
using Plots
using Dates

#ENV["GKSwstype"]="nul" # from batch / no X11

y=[1.0*i*i for i in 1:10]
@. y= -y + 5.0

# x=[i+0.0 for i in 1:10]
x=[Date(2019,11,i) for i in 1:10]


p=plot(x,y, label="y", title="Vspan problem with dates")
if sf; savefig(p,"p-plot"*ext); end

if sf; savefig(p,"p-vspan"*ext); end

Here is the (incorrect ?) result

What can I do to go around this ?
Thanks in advance,

1 Like

Maybe file an issue with Plots.jl - I remember having this issue with vline which got fixed a while ago, maybe that fix wasn’t transposed to vspan

Thank you @nilshg ! You are right, the problem was fixed inside vline, while it remains in vspan (and bar ?).
But this gave me the following go-around : if i do an additional vline!, this fixes the y axis scale ! :slight_smile:

  p=vline!(p,[rx[1]], label="",alpha=0.0)

So, thank you for helping solve my problem.

1 Like

Haha, nice one, glad that worked!