Marking specific dates when visualizing a time series

Viewed 2903

I have a time series that has a few years' worth of data, for example this:

ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000', periods=1000))

ts = ts.cumsum()

ts.plot()

I also have two extra arrays: let's call the first

dates = [pd.datetime("2000-12-01"), pd.datetime("2001-01-03")]

And the second

labels = ["My birthday", "My dad's birthday"]

labels[i] contains the label for dates[i]. What I'd like to do is to display them in the time series graph so that they can be recognized. One possible visualization could be to display the date on the x axis, draw a vertical line starting from there and have the label either in a legend (with color coding) or somewhere next to the line.

The end result shouldn't be too different from this:

ExampleGraph

1 Answers
Related