1. Learn
  2. /
  3. Courses
  4. /
  5. Visualizing Time Series Data in R

Exercise

A fancy stock chart (2)

In this exercise, you will add a legend to the chart that you just created containing the name of the companies and the dates and values of the latest dividends.

Fill in the pre-written code with the following variables containing the dividend values and dates for both companies:

  • citi_div_value
  • citi_div_date
  • micro_div_value
  • micro_div_date

Recall that the default color of a plotted line is black, and that the values for legend, col, and lty in legend() should be set to vectors of the same length as the number of time series plotted in your chart.

If you can't see all of the legend, try making the chart full screen after you plot it. Let's make our chart even fancier!

Instructions

100 XP
  • Create the same plot as in the previous exercise (this has been done for you)
  • Use the pre-loaded variables above to create the strings, micro and citi, to be used in the legend
  • "Microsoft div of $0.39 on 15 Nov. 2016"
  • "Citigroup div of $0.16 on 13 Nov. 2016"
  • Create the legend on the bottom right corner of the chart using the micro and citi strings you just created for the text, appropriate colors for the labels, and regular lines