This is an R Markdown document showing an example of a simple interactive time-series chart created with plotly.

load Packages and Source Data

#Load packages
library(plotly)
library(quantmod)

# Download data
getSymbols(Symbols = c("AMZN"))
df <- data.frame(Date = index(AMZN), AMZN[,6])

Generate a Plotly Line Chart

Hover over the line to see a specific point’s price and the Month-Year date.

p <- plot_ly(df, x = df$Date, y = df$AMZN.Adjusted, type="scatter" , mode="lines" ) %>%
    layout(
    title = "Amazon Stock Price",
    xaxis = list(x = df$Date),
    yaxis = list(title = "Price"))

#print the Plotly Chart Object
p