# Get this figure: fig <- get_figure("empet", 6640) # Get this figure's data: data <- get_figure("empet", 6640)$data # Add data to this figure: p <- add_trace(p, x=c(4, 5), y=c(4, 5), kwargs=list(filename="Nobel-women", fileopt="extend")) # Get y data of first trace: y1 <- get_figure("empet", 6640)$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( mode = "markers", name = "Peace", type = "scatter", x = c(3.2969342473519356, 4.3345552364653255, 4.650404299816229, 0.4778690098170113, -1.3313029355543482, -0.1880252594841032, 1.6637002419685682, 1.029821453689486, 3.288027252466515, 0.9610573064560768, -2.8088194255170396, -0.3416827482935716, 1.982877191657595, 4.239802304172883, -0.5453423930766661, 1.2823099938250326), y = c(-0.29759475971996197, 1.0, -0.1980449486452205, -1.7991080329334874, -4.254800567306541, 3.3677510017684416, -4.542630813729614, -0.9666280921245507, -1.3232891800029578, -3.2534417736699184, -0.7139618240804158, -2.835192179567816, -2.5961752368654913, -1.5722325108560753, 1.4740910752053331, 1.6574204503207524), marker = list( line = list( color = "#000000", width = 0.5 ), size = 20, color = "#74f2b8", symbol = "dot" ), text = c("Malala Yousafzai
2014", "Ellen Johnson Sirleaf
2011", "Leymah Gbowee
2011", "Tawakkol Karman
2011", "Wangari Muta Maathai
2004", "Shirin Ebadi
2003", "Jody Williams
1997", "Rigoberta Menchú Tum
1992", "Aung San Suu Kyi
1991", "Alva Myrdal
1982", "Mother Teresa
1979", "Betty Williams
1976", "Mairead Corrigan
1976", "Emily Greene Balch
1946", "Jane Addams
1931", "Bertha von Suttner
1905"), hoverinfo = "text" ) trace2 <- list( mode = "markers", name = "Literature", type = "scatter", x = c(-11.346367331673886, -11.013150028270836, -13.264699081017008, -12.200293624991449, -8.121354734272433, -9.784273158655392, -13.981118777945786, -8.552553568139965, -6.8588139536077275, -7.436202994571332, -8.491045302333855, -10.655068949360038, -6.958652280664409, -8.5), y = c(-10.267350402144276, -12.339459181663747, -10.644049610653703, -12.40761134438331, -13.175565198071222, -11.354573554949118, -9.699928156692748, -11.518453199778804, -10.134100922619936, -6.330937776561807, -9.751766072152222, -7.181302649120698, -11.474639928968902, -8), marker = list( line = list( color = "#000000", width = 0.5 ), size = 20, color = "#f28dce", symbol = "dot" ), text = c("Svetlana Alexievich
2015", "Alice Munro
2013", "Herta Müller
2009", "Doris Lessing
2007", "Elfriede Jelinek
2004", "Wislawa Szymborska
1996", "Toni Morrison
1993", "Nadine Gordimer
1991", "Nelly Sachs
1966", "Gabriela Mistral
1945", "Pearl Buck
1938", "Sigrid Undset
1928", "Grazia Deledda
1926", "Selma O.L. Lagerlof
1909"), hoverinfo = "text" ) trace3 <- list( mode = "markers", name = "Medicine", type = "scatter", x = c(3.152925262242168, 8.071781750138467, 6.156591859944132, 4.0897554420454885, 6.785466479022956, 7.654723501256321, 2.1365276564826807, 2.0133248548894045, 5.260697060772697, 5.40401872045347, 7.351291756040962, 4.384273298170313), y = c(-9.551589807623499, -10.840222580393814, -10.134181839861341, -12.240276309259727, -8.180786812131934, -13.738495369288756, -13.427396526362257, -10.114049691279423, -8.731540110678411, -13.096395924609784, -12.077257789700248, -11.347804963623746), marker = list( line = list( color = "#000000", width = 0.5 ), size = 20, color = "#7c8efb", symbol = "dot" ), text = c("Youyou Tu
2015", "May-Britt Moser
2014", "Elizabeth H. Blackburn
2009", "Carol W. Greider
2009", "Françoise Barré-Sinoussi
2008", "Linda B. Buck
2004", "Christiane Nüsslein-Volhard
1995", "Gertrude B. Elion
1988", "Rita Levi-Montalcini
1986", "Barbara McClintock
1983", "Rosalyn Yalow
1977", "Gerty Theresa Cori
1947"), hoverinfo = "text" ) trace4 <- list( mode = "markers", name = "Chemistry", type = "scatter", x = c(-10.666829160205287, -8.628976596579768, -7.596683180567988, -9.054570266194336), y = c(-2.1334353058719056, -1.4814835783069502, -0.2372855624382737, -0.2592100764012695), marker = list( line = list( color = "#FFFFFF", width = 0.5 ), size = 20, color = "#fcb19b", symbol = "dot" ), text = c("Ada E. Yonath
2009", "Dorothy Crowfoot Hodgkin
1964", "Irène Joliot-Curie
1935", "Marie Curie
1911"), hoverinfo = "text" ) trace5 <- list( mode = "markers", name = "Physics", type = "scatter", x = c(9.8, 8), y = c(3.2, 4), marker = list( line = list( color = "#000000", width = 0.5 ), size = 20, color = "#fefe9a", symbol = "dot" ), opacity = 0.9, text = c("Maria Goeppert Mayer
1963", "Marie Curie
1903"), hoverinfo = "text" ) trace6 <- list( mode = "markers", name = "Economy", text = "Elinor Ostrom
2009", type = "scatter", x = c(-3), y = c(-7), marker = list( line = list( color = "#FFFFFF", width = 0.5 ), size = 20, color = "rgb(180,42,107)", symbol = "dot" ), opacity = 0.75, hoverinfo = "text" ) data <- list(trace1, trace2, trace3, trace4, trace5, trace6) layout <- list( title = "Nobel Prize Awarded Women", width = 650, xaxis = list( ticks = "", mirror = TRUE, showgrid = FALSE, showline = TRUE, zeroline = FALSE, showticklabels = FALSE ), yaxis = list( ticks = "", mirror = TRUE, showgrid = FALSE, showline = TRUE, zeroline = FALSE, showticklabels = FALSE ), height = 525, margin = list( b = 80, l = 80, r = 200, t = 100 ), hovermode = "closest", annotations = list( list( x = 0, y = -0.14, font = list(size = 0), text = "Data source: [1]", xref = "paper", yref = "paper", xanchor = "left", yanchor = "bottom", showarrow = FALSE ) ), plot_bgcolor = "rgb(50,50,50)" ) p <- plot_ly() p <- add_trace(p, mode=trace1$mode, name=trace1$name, type=trace1$type, x=trace1$x, y=trace1$y, marker=trace1$marker, text=trace1$text, hoverinfo=trace1$hoverinfo) p <- add_trace(p, mode=trace2$mode, name=trace2$name, type=trace2$type, x=trace2$x, y=trace2$y, marker=trace2$marker, text=trace2$text, hoverinfo=trace2$hoverinfo) p <- add_trace(p, mode=trace3$mode, name=trace3$name, type=trace3$type, x=trace3$x, y=trace3$y, marker=trace3$marker, text=trace3$text, hoverinfo=trace3$hoverinfo) p <- add_trace(p, mode=trace4$mode, name=trace4$name, type=trace4$type, x=trace4$x, y=trace4$y, marker=trace4$marker, text=trace4$text, hoverinfo=trace4$hoverinfo) p <- add_trace(p, mode=trace5$mode, name=trace5$name, type=trace5$type, x=trace5$x, y=trace5$y, marker=trace5$marker, opacity=trace5$opacity, text=trace5$text, hoverinfo=trace5$hoverinfo) p <- add_trace(p, mode=trace6$mode, name=trace6$name, text=trace6$text, type=trace6$type, x=trace6$x, y=trace6$y, marker=trace6$marker, opacity=trace6$opacity, hoverinfo=trace6$hoverinfo) p <- layout(p, title=layout$title, width=layout$width, xaxis=layout$xaxis, yaxis=layout$yaxis, height=layout$height, margin=layout$margin, hovermode=layout$hovermode, annotations=layout$annotations, plot_bgcolor=layout$plot_bgcolor)