1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Data Visualization with Plotly in Python

Connected

Exercise

Finance line chart with custom time buttons

You have been engaged by an Excel-savvy finance trading company to help them jazz up their data visualization capabilities. Safe to say, Excel graphics aren't cutting it for them!

The fund is particularly interested in a pharmaceutical company and how it has performed this year and wants a tool to help them zoom in on key timeframes.

In this exercise, you will help the trading company by visualizing the opening stock price of the company over 2020 and creating the following date-filter buttons:

  • 1WTD = The previous week (7 days to date)
  • 6MTD = The previous 6 months week (6 months to date)
  • YTD = The current year to date

You have a stock_price DataFrame available that contains the necessary data.

Instructions

100 XP
  • Create a line chart of the stock_price DataFrame using the Date and Open columns.
  • Create a list called fin_buttons containing the custom date-filter buttons mentioned above.
  • Update the figure using .update_layout() to construct buttons using your created list.