# Get this figure: fig <- get_figure("EricBerry", 180) # Get this figure's data: data <- get_figure("EricBerry", 180)$data # Add data to this figure: p <- add_trace(p, x=c(4, 5), y=c(4, 5), kwargs=list(filename="Distributions of lengths of consumer reviews of Bounty, Viva, and Brawny", fileopt="extend")) # Get x data of first trace: x1 <- get_figure("EricBerry", 180)$data[[1]]$x # 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( uid = "63ecfb", name = "Viva Mainline", type = "histogram", x = c("15", "45", "12", "21", "84", "34", "87", "18", "12", "18", "14", "16", "20", "17", "76", "94", "16", "14", "11", "26", "19", "20", "12", "27", "35", "27", "31", "54", "14", "27", "11", "10", "14", "27", "13", "52", "13", "24", "18", "70", "24", "10", "16", "24", "15", "25", "36", "22", "32", "12", "32", "12", "16", "20", "33", "49", "12", "42", "9", "14", "20", "12", "15", "19", "36", "17", "30", "39", "15", "40", "37", "22", "22", "32", "12", "12", "21", "15", "23", "24", "39", "16", "13", "16", "115", "23", "21", "46", "12", "23", "31", "20", "14", "26", "58", "131", "34", "97", "108", "51", "24", "108", "15", "34", "47", "59", "44", "65", "17", "9", "104", "15", "9", "89", "29", "51", "17", "59", "29", "65", "41", "125", "92", "29", "17", "38", "24", "61", "13", "27", "18", "32", "41", "9", "50", "65", "94", "16", "50", "67", "94", "110", "16", "21", "76", "56", "143", "22", "66", "82", "87", "12", "64", "156", "14", "129", "84", "70", "91", "58", "43", "68", "18", "38", "48", "26", "21", "13", "12", "29", "25", "12", "53", "12", "10", "37", "19", "16", "14", "13", "10", "11", "28", "9", "34", "32", "13", "17", "72", "50", "11", "67", "40", "14", "53", "43", "43", "12", "12", "18", "27", "18", "152", "45", "98", "15", "66", "95", "76", "99", "13", "108", "78", "63", "180", "82", "42", "183", "126", "28"), xbins = list( end = 189.5, size = 7, start = 4.5 ), marker = list( line = list( color = "#444", width = 0.8 ), color = "rgb(227, 119, 194)" ), opacity = 1, autobinx = FALSE, histnorm = "" ) trace2 <- list( uid = "9d2686", name = "Vantage", type = "histogram", x = c("10", "24", "32", "42", "83", "25", "29", "15", "64", "19", "14", "24", "16", "41", "29", "10", "27", "29", "16", "10", "12", "22", "20", "21", "61", "91", "46", "62", "12", "11", "29", "18", "19", "43", "14", "18", "19", "10", "11", "13", "20", "28", "42", "9", "28", "11", "30", "13", "12", "21", "26", "10", "23", "20", "27", "10", "10", "24", "17", "54", "12", "17", "27", "28", "14", "36", "71", "15", "80", "11", "10", "30", "14", "16", "18", "80", "15", "10", "9", "19", "19", "10", "51", "49", "41", "46", "47", "31", "27", "16", "18", "6", "24", "65", "34", "14", "23", "31", "9", "22", "58", "13", "24", "28", "11", "25", "16", "37", "20", "12", "27", "56", "28", "10", "57", "10", "114", "10", "10", "14", "11", "18", "31", "36", "17", "21", "10", "26", "23", "11", "25", "19", "12", "13", "36", "11", "62", "50", "34", "10", "43", "12", "11", "18", "19", "31", "21", "21", "19", "23", "11", "10", "11", "21", "27", "28", "12", "31", "30", "10", "20", "10", "12", "12", "36", "35", "24", "22", "9", "13", "9", "19", "37", "33", "14", "12", "16", "14", "28", "54", "37", "13", "31", "34", "13", "19", "20", "10", "17", "45", "11", "16", "13", "10", "17", "10", "11", "20", "40", "21", "11", "25", "17", "14", "28", "14", "17", "23", "11", "37", "67", "21", "14", "14", "14", "20", "19", "47", "12", "17", "16", "38", "15", "18"), xbins = list( end = 114.5, size = 7, start = 4.5 ), marker = list( line = list( color = "#444", width = 0.8 ), color = "rgb(148, 103, 189)" ), opacity = 1, autobinx = FALSE, histnorm = "" ) trace3 <- list( uid = "55f011", name = "Brawny", type = "histogram", x = c("40", "40", "25", "30", "24", "12", "33", "15", "38", "31", "14", "11", "16", "9", "40", "14", "15", "11", "50", "59", "24", "18", "11", "12", "13", "10", "9", "11", "8", "19", "23", "43", "47", "14", "31", "29", "33", "11", "19", "21", "10", "10", "54", "17", "15", "26", "20", "9", "34", "21", "21", "12", "34", "12", "19", "16", "14", "8", "54", "39", "8", "30", "15", "25", "11", "17", "22", "30", "12", "11", "13", "11", "20", "10", "13", "10", "13", "13", "16", "12", "12", "13", "41", "10", "21", "11", "8", "33", "26", "15", "22", "22", "26", "18", "15", "12", "16", "14", "12", "9", "10", "7", "14", "13", "15", "39", "14", "63", "15", "12", "13", "12", "57", "15", "16", "10", "13", "10", "12", "10", "12", "23", "12", "12", "32", "11", "18", "24", "10", "13", "16", "28", "20", "13", "11", "16", "11", "11", "16", "15", "30", "16", "19", "10", "13", "8", "106", "15", "25", "15", "12", "14", "86", "23", "32", "20", "57", "10", "32", "17", "19", "112", "19", "13", "11", "38", "16", "67", "43", "29", "55", "67", "57", "51", "84", "54", "29", "30", "18", "75", "34", "59", "15", "23", "22", "75", "48", "20", "13", "37", "18", "40", "65", "9", "22", "13", "11", "54", "38", "8", "77", "31", "11", "65", "70", "73", "55", "22", "106", "27", "15", "9", "18", "28", "45", "14", "31", "27", "34", "10", "10", "27", "9", "9", "31"), xbins = list( end = 114.5, size = 7, start = 4.5 ), marker = list( line = list( color = "black", width = 0.8 ), color = "rgb(255, 0, 0)" ), opacity = 0.7, autobinx = FALSE ) trace4 <- list( uid = "38c282", name = "Bounty", type = "histogram", x = c("90", "96", "66", "100", "80", "86", "86", "137", "181", "59", "66", "85", "87", "82", "51", "36", "115", "180", "80", "24", "28", "86", "84", "116", "76", "82", "58", "32", "84", "49", "60", "90", "99", "177", "46", "30", "30", "10", "19", "101", "54", "138", "66", "46", "59", "31", "67", "115", "175", "52", "62", "43", "70", "100", "124", "36", "46", "19", "9", "14", "24", "131", "39", "37", "21", "61", "71", "64", "54", "43", "25", "45", "18", "54", "26", "134", "15", "33", "27", "34", "33", "18", "33", "44", "11", "30", "21", "41", "53", "61", "43", "30", "28", "86", "60", "76", "32", "59", "40", "32", "41", "26", "63", "12", "59", "10", "31", "34", "43", "20", "39", "32", "34", "23", "21", "27", "26", "40", "30", "37", "15", "14", "19", "35", "14", "18", "17", "63", "24", "10", "69", "14", "10", "11", "81", "46", "42", "17", "66", "23", "24", "21", "15", "73", "42", "77", "22", "65", "16", "9", "19", "25", "27", "12", "35", "25", "39", "50", "69", "70", "18", "33", "33", "42", "119", "65", "14", "21", "66", "117", "32", "22", "49", "31", "21", "33", "32", "11", "49", "31", "17", "37", "47", "86", "102", "19", "159", "25", "27", "122", "37", "16", "78", "36", "63", "65", "25", "41", "102", "81", "141", "36", "41", "71", "37", "85", "76", "107", "41", "58", "136", "52", "86", "86", "44", "88", "19", "120", "66", "159", "40", "10", "17", "100"), xbins = list( end = 189.5, size = 7, start = -0.5 ), marker = list( line = list( color = "black", width = 0.8 ), color = "rgba(44, 160, 44, 0.59)" ), opacity = 0.7, autobinx = FALSE ) data <- list(trace1, trace2, trace3, trace4) layout <- list( font = list( size = 12, color = "#444", family = "\"Open sans\", verdana, arial, sans-serif" ), title = "Distributions of lengths of consumer reviews of Bounty, Viva, and Brawny", width = 827, xaxis = list( type = "linear", range = c(4.5, 186.5), ticks = "", title = "Number of words", mirror = FALSE, nticks = 0, ticklen = 6, showgrid = TRUE, showline = FALSE, tickfont = list( size = 12, color = "#444", family = "\"Open sans\", verdana, arial, sans-serif" ), tickmode = "auto", zeroline = FALSE, autorange = TRUE, gridcolor = "rgb(255, 255, 255)", gridwidth = 2, linecolor = "rgba(152, 0, 0, 0.5)", linewidth = 1.5, rangemode = "normal", tickangle = "auto", tickcolor = "rgba(0, 0, 0, 0)", titlefont = list( size = 14, color = "#444", family = "\"Open sans\", verdana, arial, sans-serif" ), showexponent = "all", zerolinewidth = 1, exponentformat = "B", showticklabels = TRUE ), yaxis = list( type = "linear", range = c(-3.1976638072640995, 77.01040335827706), ticks = "", title = "Number of reviews", mirror = FALSE, nticks = 0, ticklen = 6, showgrid = TRUE, showline = FALSE, tickfont = list( size = 12, color = "#444", family = "\"Open sans\", verdana, arial, sans-serif" ), tickmode = "auto", zeroline = FALSE, autorange = TRUE, gridcolor = "rgb(255, 255, 255)", gridwidth = 2, linecolor = "rgba(152, 0, 0, 0.5)", linewidth = 1.5, rangemode = "normal", tickangle = "auto", tickcolor = "rgba(0, 0, 0, 0)", titlefont = list( size = 14, color = "#444", family = "\"Open sans\", verdana, arial, sans-serif" ), showexponent = "all", zerolinewidth = 1, exponentformat = "B", showticklabels = TRUE ), bargap = 0, height = 481, legend = list( x = 0.7978883861236803, y = 0.9634551495016611, font = list( size = 12, color = "#444", family = "\"Open sans\", verdana, arial, sans-serif" ), bgcolor = "rgba(255, 255, 255, 0.75)", traceorder = "normal", bordercolor = "rgba(0, 0, 0, 0)", borderwidth = 1 ), barmode = "overlay", autosize = TRUE, dragmode = "zoom", hovermode = "x", titlefont = list( size = 17, color = "#444", family = "\"Open sans\", verdana, arial, sans-serif" ), separators = ".,", showlegend = TRUE, annotations = list( list( x = 42, y = 0, ax = 0, ay = -290, text = "", arrowhead = 0, arrowcolor = "rgb(44, 160, 44)", arrowwidth = 4 ), list( x = 27, y = 0, ax = 0, ay = -290, text = "", arrowhead = 0, arrowcolor = "rgb(227, 119, 194)", arrowwidth = 4 ), list( x = 19, y = 0, ax = 0, ay = -290, text = "", arrowhead = 0, arrowcolor = "rgb(148, 103, 189)", arrowwidth = 4 ), list( x = 17, y = 0, ax = 0, ay = -290, text = "", arrowhead = 0, arrowcolor = "rgb(255, 0, 0)", arrowwidth = 4 ), list( x = 69, y = 72, ax = 0, ay = 0, font = list(color = "rgb(44, 160, 44)"), text = "Median Bounty review: 42 words", arrowhead = 0, arrowcolor = "rgb(44, 160, 44)" ), list( x = 70, y = 67, ax = 0, ay = 0, font = list(color = "rgb(227, 119, 194)"), text = "Median Mainline review: 27 words" ), list( x = 70, y = 62, ax = 0, ay = 0, font = list(color = "rgb(148, 103, 189)"), text = "Median Vantage review: 19 words" ), list( x = 69, y = 57, ax = 0, ay = 0, font = list(color = "rgb(255, 0, 0)"), text = "Median Brawny review: 17 words" ) ), bargroupgap = 0.2, hidesources = FALSE, plot_bgcolor = "rgb(245, 245, 245)", paper_bgcolor = "#fff" ) p <- plot_ly() p <- add_trace(p, uid=trace1$uid, name=trace1$name, type=trace1$type, x=trace1$x, xbins=trace1$xbins, marker=trace1$marker, opacity=trace1$opacity, autobinx=trace1$autobinx, histnorm=trace1$histnorm) p <- add_trace(p, uid=trace2$uid, name=trace2$name, type=trace2$type, x=trace2$x, xbins=trace2$xbins, marker=trace2$marker, opacity=trace2$opacity, autobinx=trace2$autobinx, histnorm=trace2$histnorm) p <- add_trace(p, uid=trace3$uid, name=trace3$name, type=trace3$type, x=trace3$x, xbins=trace3$xbins, marker=trace3$marker, opacity=trace3$opacity, autobinx=trace3$autobinx) p <- add_trace(p, uid=trace4$uid, name=trace4$name, type=trace4$type, x=trace4$x, xbins=trace4$xbins, marker=trace4$marker, opacity=trace4$opacity, autobinx=trace4$autobinx) 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, barmode=layout$barmode, autosize=layout$autosize, dragmode=layout$dragmode, hovermode=layout$hovermode, titlefont=layout$titlefont, separators=layout$separators, showlegend=layout$showlegend, annotations=layout$annotations, bargroupgap=layout$bargroupgap, hidesources=layout$hidesources, plot_bgcolor=layout$plot_bgcolor, paper_bgcolor=layout$paper_bgcolor)