Is there a way to make an annotation for time series axis in Gadfly?

I’m trying to draw a line on X-axis with time series dataset

Here is a minimal working example

using Gadfly, Compose
y = broadcast(i -> i^2, 1:30)

line_anno = compose(context(), stroke("red"), Shape.line([(10, 0), (10, 1000)]))

# works fine
plot(x = 1:30, y = y, Geom.line, Guide.annotation(line_anno))

# do not work
x = broadcast(i -> DateTime(2000, 1, i), 1:30)
plot(x = x, y = y, Geom.line, Guide.annotation(line_anno))

# do not work either
d = Date(2000, 1, 10)
date_anno = compose(context(), stroke("red"), Shape.line([(d, 0), (d, 1000)]))

thank you :slight_smile:

From the gadfly documentation you could try

x = map(i -> Date(2000, 1, i), 1:30)
plot(x = x, y = y, Geom.line, Guide.xticks(orientation=:vertical),
    xintercept=[x[6], x[20]], Geom.line, Geom.vline(style=[:solid]))

Hope this helps

Thank you
that was What I wanted, I dind’t lookup doc hard enough…

I found out this works too.

date_anno = compose(context(), stroke("red"), Shape.line([(100px, 0px), (100px, 1000px)]))
plot(x = x, y = y, Geom.line, Guide.annotation(date_anno))