# Get this figure: fig <- get_figure("tccorrigan1", 9) # Get this figure's data: data <- get_figure("tccorrigan1", 9)$data # Add data to this figure: p <- add_trace(p, x=c(4, 5), y=c(4, 5), kwargs=list(filename="Nielsen Rating for Top TV Show by Season, 1950-2015 (copy) (2)", fileopt="extend")) # Get y data of first trace: y1 <- get_figure("tccorrigan1", 9)$data[[1]]$y # Get figure documentation: https://plotly.com/r/get-requests/ # Add data documentation: https://plotly.com/r/file-options/ # You can reproduce this figure in R with the following code! # Learn about API authentication here: https://plotly.com/r/getting-started # Find your api_key here: https://plotly.com/settings/api library(plotly) trace1 <- list( x = c("50–51", "51–52", "52–53", "53–54", "54–55", "55–56", "56–57", "57–58", "58–59", "59–60", "60–61", "61–62", "62–63", "63–64", "64–65", "65–66", "66–67", "67–68", "68–69", "69–70", "70–71", "71–72", "72–73", "73–74", "74–75", "75–76", "76–77", "77–78", "78–79", "79–80", "80–81", "81–82", "82–83", "83–84", "84–85", "85–86", "86–87", "87–88", "88–89", "89–90", "90–91", "91–92", "92–93", "93–94", "94–95", "95–96", "96–97", "97–98", "98–99", "99–00", "00–01", "01–02", "02–03", "03–04", "04–05", "05–06", "06–07", "07–08", "08–09", "09–10", "10–11", "11–12", "12–13", "13–14", "14–15", "15-16"), y = c("61.6", "53.8", "67.3", "58.8", "49.3", "47.5", "43.7", "43.1", "39.6", "40.3", "37.3", "32.1", "36", "39.1", "36.3", "31.8", "29.1", "27.6", "31.8", "26.3", "29.6", "34", "33.3", "31.2", "30.2", "30.1", "31.5", "31.6", "30.5", "28.4", "34.5", "28.4", "25.5", "25.7", "25", "33.7", "34.9", "27.8", "25.6", "23.1", "21.3", "21.9", "21.9", "20.9", "20.6", "22", "21.2", "21.7", "17.8", "18.6", "17.4", "15", "16.3", "15.9", "16.5", "17.6", "17.3", "16.1", "15.1", "13.7", "14.5", "12.4", "13.5", "12.6", "12.3", "-"), uid = "6cbcef", mode = "lines+markers", name = "Rating", text = c("Texaco Star Theater", "Arthur Godfrey's Talent Scouts", "I Love Lucy", "I Love Lucy", "I Love Lucy", "The $64,000 Question", "I Love Lucy", "Gunsmoke", "Gunsmoke", "Gunsmoke", "Gunsmoke", "Wagon Train", "The Beverly Hillbillies", "The Beverly Hillbillies", "Bonanza", "Bonanza", "Bonanza", "The Andy Griffith Show", "Rowan & Martin's Laugh-In", "Rowan & Martin's Laugh-In", "Marcus Welby, M.D.", "All in the Family", "All in the Family", "All in the Family", "All in the Family", "All in the Family", "Happy Days", "Laverne & Shirley", "Laverne & Shirley", "60 Minutes", "Dallas", "Dallas", "60 Minutes", "Dallas", "Dynasty", "The Cosby Show", "The Cosby Show", "The Cosby Show", "The Cosby Show", "The Cosby Show & Rosanne (tie)", "Cheers", "60 Minutes", "60 Minutes", "60 Minutes", "Seinfeld", "ER", "ER", "Seinfeld", "ER", "Who Wants to Be a Millionaire? — Tuesdays", "Survivor: The Australian Outback", "Friends", "CSI: Crime Scene Investigation", "CSI: Crime Scene Investigation", "CSI: Crime Scene Investigation", "American Idol — Tuesday", "American Idol — Wednesday", "American Idol — Tuesday", "American Idol — Wednesday", "American Idol — Tuesday", "American Idol — Wednesday", "Sunday Night Football", "NCIS", "Sunday Night Football & NCIS (tie)", "Sunday Night Football", "-"), type = "scatter", xsrc = "tccorrigan1:0:a97151", ysrc = "tccorrigan1:0:3c5efc", xbins = list( end = 64.5, size = 1, start = -0.5 ), domain = list(y = c(0.01)), marker = list( line = list( color = "#444", width = 0 ), color = "#1f77b4", colors = "#1f77b4" ), error_x = list(copy_ystyle = TRUE), error_y = list( color = "rgb(0, 67, 88)", width = 1, thickness = 1 ), opacity = 1, textsrc = "tccorrigan1:0:7fda7c", autobinx = TRUE, autobiny = TRUE, hoverinfo = "all" ) data <- list(trace1) layout <- list( font = list( size = 12, color = "#444", family = "\"Open Sans\", verdana, arial, sans-serif" ), title = "Nielsen Rating for Top TV Show by Season, 1960-2015", width = 952, xaxis = list( type = "category", dtick = 5, range = c(9.685596016054227, 68.98142795745926), tick0 = 0, ticks = "inside", title = "Season", tickmode = "linear", autorange = FALSE, tickangle = 40 ), yaxis = list( type = "linear", range = c(8.552434746262016, 45.79925499421842), title = "Nielsen Rating", autorange = FALSE ), bargap = 0.2, height = 502, legend = list( x = 0.02, y = 1, bgcolor = "rgba(255, 255, 255, 0.5)" ), autosize = TRUE, dragmode = "zoom", hovermode = "x", titlefont = list( size = 17, color = "#444", family = "\"Open Sans\", verdana, arial, sans-serif" ), separators = ".,", annotations = list( list( x = 3.0290404040404013, y = 67.12057392476247, ax = 58, ay = 23, font = list( size = 14, color = "#444", family = "\"Open Sans\", verdana, arial, sans-serif" ), text = "I Love Lucy", bgcolor = "rgba(0, 0, 0, 0)", opacity = 1, arrowhead = 1, arrowsize = 1, borderpad = 1, textangle = 0, arrowcolor = "#444", arrowwidth = 2, bordercolor = "rgba(0, 0, 0, 0)", borderwidth = 1 ), list( x = 13.3, y = 40.24923864282554, ax = 42, ay = -31, font = list( size = 14, color = "#444", family = "\"Open Sans\", verdana, arial, sans-serif" ), text = "The Beverly Hillbillies", bgcolor = "rgba(0, 0, 0, 0)", opacity = 1, arrowhead = 1, arrowsize = 1, borderpad = 1, textangle = 0, arrowcolor = "#444", arrowwidth = 2, bordercolor = "rgba(0, 0, 0, 0)", borderwidth = 1 ), list( x = 6.499655422794511, y = 42.15823014080041, ax = -26, ay = 31, font = list( size = 14, color = "#444", family = "\"Open Sans\", verdana, arial, sans-serif" ), text = "Gunsmoke", bgcolor = "rgba(0, 0, 0, 0)", opacity = 1, arrowhead = 1, arrowsize = 1, borderpad = 1, textangle = 0, arrowcolor = "#444", arrowwidth = 2, bordercolor = "rgba(0, 0, 0, 0)", borderwidth = 1 ), list( x = 21.330808080808076, y = 35.362089000359866, ax = 24, ay = -39, font = list( size = 14, color = "#444", family = "\"Open Sans\", verdana, arial, sans-serif" ), text = "All in the Family", bgcolor = "rgba(0, 0, 0, 0)", opacity = 1, arrowhead = 1, arrowsize = 1, borderpad = 1, textangle = 0, arrowcolor = "#444", arrowwidth = 2, bordercolor = "rgba(0, 0, 0, 0)", borderwidth = 1 ), list( x = 30.076515151515153, y = 35.680583812472356, ax = 12, ay = -30, font = list( size = 14, color = "#444", family = "\"Open Sans\", verdana, arial, sans-serif" ), text = "Dallas", bgcolor = "rgba(0, 0, 0, 0)", opacity = 1, arrowhead = 1, arrowsize = 1, borderpad = 1, textangle = 0, arrowcolor = "#444", arrowwidth = 2, bordercolor = "rgba(0, 0, 0, 0)", borderwidth = 1 ), list( x = 36.43181818181818, y = 36.24359418824738, ax = 24, ay = -30, font = list( size = 14, color = "#444", family = "\"Open Sans\", verdana, arial, sans-serif" ), text = "The Cosby Show", bgcolor = "rgba(0, 0, 0, 0)", opacity = 1, arrowhead = 1, arrowsize = 1, borderpad = 1, textangle = 0, arrowcolor = "#444", arrowwidth = 2, bordercolor = "rgba(0, 0, 0, 0)", borderwidth = 1 ), list( x = 44.55681818181818, y = 23.359887479019065, ax = -24, ay = -30, font = list( size = 14, color = "#444", family = "\"Open Sans\", verdana, arial, sans-serif" ), text = "ER", bgcolor = "rgba(0, 0, 0, 0)", opacity = 1, arrowhead = 1, arrowsize = 1, borderpad = 1, textangle = 0, arrowcolor = "#444", arrowwidth = 2, bordercolor = "rgba(0, 0, 0, 0)", borderwidth = 1 ), list( x = 47.34722222222222, y = 23.359887479019065, ax = 24, ay = -30, font = list( size = 14, color = "#444", family = "\"Open Sans\", verdana, arial, sans-serif" ), text = "Seinfeld", bgcolor = "rgba(0, 0, 0, 0)", opacity = 1, arrowhead = 1, arrowsize = 1, borderpad = 1, textangle = 0, arrowcolor = "#444", arrowwidth = 2, bordercolor = "rgba(0, 0, 0, 0)", borderwidth = 1 ), list( x = 54.733585858585855, y = 19.393114133525263, font = list( size = 14, color = "#444", family = "\"Open Sans\", verdana, arial, sans-serif" ), text = "American Idol", bgcolor = "rgba(0, 0, 0, 0)", opacity = 1, arrowhead = 1, arrowsize = 1, borderpad = 1, textangle = 0, arrowcolor = "#444", arrowwidth = 2, bordercolor = "rgba(0, 0, 0, 0)", borderwidth = 1 ), list( x = 17.935063093718984, y = 32.981013106624154, font = list(size = 14), text = "Laugh-In" ), list( x = 39.531546859492416, y = 19.60552944509444, ax = -24, ay = 30, font = list(size = 14), text = "Cheers" ), list( x = 50.39275485608961, y = 13.803365214311015, ax = -52, ay = 14, font = list(size = 14), text = "Friends" ), list( x = 61.67247979583156, y = 14.641303577754158, ax = -31, ay = -30, font = list(size = 14), text = "NCIS" ), list( x = 63.85027647809443, y = 13.498193411264609, ax = -36, ay = -112, font = list(size = 14), text = "Sunday Night Football" ) ), bargroupgap = 0, hidesources = FALSE, plot_bgcolor = "#fff", paper_bgcolor = "#fff" ) p <- plot_ly() p <- add_trace(p, x=trace1$x, y=trace1$y, uid=trace1$uid, mode=trace1$mode, name=trace1$name, text=trace1$text, type=trace1$type, xsrc=trace1$xsrc, ysrc=trace1$ysrc, xbins=trace1$xbins, domain=trace1$domain, marker=trace1$marker, error_x=trace1$error_x, error_y=trace1$error_y, opacity=trace1$opacity, textsrc=trace1$textsrc, autobinx=trace1$autobinx, autobiny=trace1$autobiny, hoverinfo=trace1$hoverinfo) p <- layout(p, font=layout$font, title=layout$title, width=layout$width, xaxis=layout$xaxis, yaxis=layout$yaxis, bargap=layout$bargap, height=layout$height, legend=layout$legend, autosize=layout$autosize, dragmode=layout$dragmode, hovermode=layout$hovermode, titlefont=layout$titlefont, separators=layout$separators, annotations=layout$annotations, bargroupgap=layout$bargroupgap, hidesources=layout$hidesources, plot_bgcolor=layout$plot_bgcolor, paper_bgcolor=layout$paper_bgcolor)