Next, let’s set up our plot using the plotly library.
library(plotly)
plotOfMovieRatingsCI = plot_ly(x = 1990:2000, y = sampleMeansOfPopulation,
type = "scatter", mode = "lines+markers",
marker = list(color = "green"), line = list(color = "green"),
name = "Sample Means") %>%
add_trace(x = 1990:2000, y = upperBoundOfConfidenceIntervals,
marker = list(color = "red", symbol = "square"),
line = list(color = "red"), name = "Upper Bounds") %>%
add_trace(x = 1990:2000, y = lowerBoundOfConfidenceIntervals,
marker = list(color = "red", symbol = "x"),
line = list(color = "red"), name = "Lower Bounds") %>%
layout(title = "Confidence Intervals of Mean Movie Rating By Year",
xaxis = list(title = "Years"), yaxis = list(title = "Ratings"))