Get startedGet started for free

Setting up a polygon annotation

A member of a hedge fund, who is an avid sports fan, saw your work for the sports media agency and has reached out as they need some plots produced for stock market analysis.

They are looking into the online media market and have provided you with a dataset called netflix, containing stock prices for Netflix. It has been stored as a source object called source and preloaded for you.

A figure, fig, has been created containing line glyphs. They would like you to highlight a period of significant growth. You plan to use a polygon annotation to draw attention to changes in Netflix's stock price in mid-2017 and add it to the line plot. To start, you need to create the start and end dates and timestamps.

This exercise is part of the course

Interactive Data Visualization with Bokeh

View Course

Exercise instructions

  • Import PolyAnnotation.
  • Set start_date as 30th June 2017 and end_date as 27th July 2017.
  • Create start_float and end_float by calling .timestamp() and multiplying the result by 1000.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Import PolyAnnotation
____

# Create start and end dates
start_date = dt.datetime(2017, ____, ____)
end_date = dt.datetime(____, ____, ____)

# Create start and end floats
start_float = ____.____() * ____
end_float = ____.____() * ____
Edit and Run Code