# Get this figure: fig <- get_figure("etav3", 52) # Get this figure's data: data <- get_figure("etav3", 52)$data # Add data to this figure: p <- add_trace(p, x=c(4, 5), y=c(4, 5), kwargs=list(filename="Most Popular Cigarette Brands, Globally", fileopt="extend")) # Get x data of first trace: x1 <- get_figure("etav3", 52)$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 = "0ee762", name = "Cigarette Brand", type = "histogram", x = c("L & M", "Rym", "Marlboro", "Marlboro", "Winfield", "Marlboro", "West", "Marlboro", "BAT Bangladesh", "Embassy", "Neman brands", "Marlboro", "Casino", "Drina", "Derby", "Marlboro", "Victory", "London KS", "Ara", "Diplomat Menthol", "Du Maurier", "Belmont", "Chunghwa", "Boston", "Tumbaco", "Delta", "Excellence", "Ronhill", "Popular", "Rothmans Royals", "Start", "Prince", "Nacional", "Lider Suave", "Cleopatra", "Delta", "L & M", "Nyala", "Benson & Hedges", "L & M", "Marlboro", "Viceroy", "Marlboro", "London", "Marlboro", "Rubios", "Bristol", "Belmont", "Marlboro", "Soplanae", "Winston", "Wills Gold Flake", "Marlboro", "57", "Benson & Hedges", "Marlboro", "Marlboro", "Craven A", "Mild Seven", "Viceroy", "Sovereign", "Sportsman", "Esse", "Marlboro", "Rdaeng", "Marlboro", "Marlboro", "L & M", "Marlboro", "Rodeo", "Dunhill", "Rothmans", "State Express 555", "Marlboro", "Temp", "Classic", "Marquise", "Khukuri", "Marlboro", "Holiday", "Belmont", "Benson & Hedges", "Prince", "Marlboro", "Morven Gold", "Marlboro", "Kentucky", "Hamilton", "Marlboro", "L & M", "SG", "Marlboro", "L & M", "Winston", "Marlboro", "Excellence", "State Express 555", "Marlboro", "Golden Gate", "Boss", "Peter Stuyvesant", "Marlboro", "Gold Leaf", "Bringi", "Marlboro", "Marlboro", "Al Sherek", "Sweet Menthol", "Krong Thip", "Du Maurier", "20 Mars", "Samsun", "Prilucky Osoblyvi", "Marlboro", "Lambert & Butler", "Marlboro", "Nevada", "Belmont", "Vinataba", "Kamaran", "Consulate", "Madison"), xbins = list( end = 75.5, size = 1, start = -0.5 ), marker = list( line = list( color = "black", width = 0.8 ), color = "rgb(212, 189, 74)" ), opacity = 0.7 ) data <- list(trace1) layout <- list( font = list( size = 10, color = "rgb(105, 100, 124)", family = "\"Courier New\", monospace" ), title = "Most Popular Cigarette Brands, Globally", width = 1022, xaxis = list( type = "category", range = c(-0.5, 75.5), title = "Cigarette Brand", mirror = FALSE, nticks = 7, ticklen = 6, showgrid = TRUE, showline = TRUE, tickfont = list( size = 11, color = "black", family = "\"Courier New\", monospace" ), zeroline = TRUE, autorange = TRUE, gridcolor = "white", gridwidth = 1, linecolor = "rgba(152, 0, 0, 0.5)", linewidth = 1.5, tickangle = -50, tickcolor = "rgba(0, 0, 0, 0)", titlefont = list( size = 14, color = "black", family = "\"Courier New\", monospace" ), zerolinewidth = 1 ), yaxis = list( range = c(0, 31.57894736842105), title = "Popularity (count)", mirror = FALSE, nticks = 7, ticklen = 6, showgrid = TRUE, showline = TRUE, tickfont = list( size = 11, color = "black", family = "\"Courier New\", monospace" ), zeroline = TRUE, autorange = TRUE, gridcolor = "white", gridwidth = 1, linecolor = "rgba(152, 0, 0, 0.5)", linewidth = 1.5, tickangle = -50, tickcolor = "rgba(0, 0, 0, 0)", titlefont = list( size = 14, color = "black", family = "\"Courier New\", monospace" ), zerolinewidth = 1 ), bargap = 0.28, height = 566, legend = list( x = 1, y = 0.5, font = list(color = "rgb(105, 100, 124)"), bgcolor = "rgb(224, 221, 220)", bordercolor = "rgb(207, 206, 202)", borderwidth = 0 ), autosize = TRUE, titlefont = list( size = 16, color = "rgb(88, 74, 77)", family = "\"Courier New\", monospace" ), annotations = list( list( x = 3.820185614849191, y = 24.86196000530394, ax = 50, ay = -50, font = list(size = 14), text = "Marlborough" ), list( x = 0.6461716937355035, y = 2.945186801199892, ax = 70, ay = -35, font = list(size = 14), text = "L & M " ) ), plot_bgcolor = "rgb(238, 235, 234)", paper_bgcolor = "rgb(238, 235, 234)" ) 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) 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, titlefont=layout$titlefont, annotations=layout$annotations, plot_bgcolor=layout$plot_bgcolor, paper_bgcolor=layout$paper_bgcolor)