1. Learn
  2. /
  3. Courses
  4. /
  5. Interactive Data Visualization with Bokeh

Connected

Exercise

Travel analysis

The hedge fund is aiming for the sky, and would like to understand the performance of airline stocks.

You will produce a line plot of stock price versus date, allowing viewers to switch between Delta Air Lines, Southwest Airlines, and Boeing. The figure and glyphs have been preloaded for you:

boeing = stocks.loc[stocks["name"] == "BA"]
delta = stocks.loc[stocks["name"] == "DAL"]
southwest = stocks.loc[stocks["name"] == "LUV"]
fig = figure(x_axis_label="Date", y_axis_label="Stock Price", 
             x_axis_type="datetime")
boeing_line = fig.line(x=boeing["date"], y=boeing["close"],
                       alpha=0.5)
delta_line = fig.line(x=delta["date"], y=delta["close"], 
                      color="red", alpha=0.5)
sw_line = fig.line(x=southwest["date"], y=southwest["close"], 
                   color="green", alpha=0.5)

Instructions

100 XP
  • Import the Select widget along with CustomJS.
  • Create the Select widget, assigning options as a list containing "Boeing", "Delta", and "Southwest" (in that order), a value of "Boeing", and a title of "Airline".
  • Set up the widget to implement the callback function on a change in "value".