# Get this figure: fig <- get_figure("TonyFast", 4) # Get this figure's data: data <- get_figure("TonyFast", 4)$data # Add data to this figure: p <- add_trace(p, x=c(4, 5), y=c(4, 5), kwargs=list(filename="plot from API (4)", fileopt="extend")) # Get y data of first trace: y1 <- get_figure("TonyFast", 4)$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( uid = "371f4f", line = list( color = "", width = 0 ), name = "15", type = "scatter", x = c(-0.0111291, -0.02751725, -0.03017277, -0.03011172, -0.02926798, -0.03643525, -0.03101163, -0.01782965, -0.01778263), y = c(0.01956448, 0.03078252, 0.0615735, 0.04791931, 0.1002016, 0.1217657, -0.07362801, 0.05789031, 0.005436112), marker = list( line = list( color = "black", width = 3 ), size = 16, color = "rgb(166,206,227)", symbol = "circle", opacity = 0.9 ), error_x = lis), error_y = lis), textfont = lis) ) trace2 <- list( uid = "9eca37", line = list( color = "", width = 0 ), name = "23", type = "scatter", x = c(-0.09085062, -0.08309718, -0.07721143, -0.08032169, -0.08266671, -0.09760333, -0.08919488, -0.1067082, -0.08262652), y = c(0.009362979, -0.03449371, -0.2519982, -0.02016662, -0.01193892, -0.04754519, -0.07898571, 0.002751064, -0.02970496), marker = list( line = list( color = "black", width = 3 ), size = 16, color = "rgb(48,131,208)", symbol = "circle", opacity = 0.9 ), error_x = lis), error_y = lis), textfont = lis) ) trace3 <- list( uid = "767b9b", line = list( color = "", width = 0 ), name = "HT11", type = "scatter", x = c(-0.1415569, -0.1494909, -0.1395377, -0.1530695, -0.1347388, -0.1530795, -0.128468, -0.148947, -0.1332723), y = c(-0.02640657, -0.01860438, -0.04419354, -0.09782245, -0.03567848, -0.02751839, -0.02723736, 0.001900022, -0.01007051), marker = list( line = list( color = "black", width = 3 ), size = 16, color = "rgb(31,120,180)", symbol = "circle", opacity = 0.9 ), error_x = lis), error_y = lis), textfont = lis) ) trace4 <- list( uid = "92d40d", line = list( color = "", width = 0 ), name = "HT14", type = "scatter", x = c(-0.04738642, -0.0008138246, 0.00239608, -0.05681301, -0.001531539, -0.01619036, -0.01471195, -0.07534351, -0.05924579), y = c(0.1217286, 0.06880765, 0.06987558, 0.0923118, 0.07917621, 0.1020779, 0.07510775, 0.1260983, 0.1034498), marker = list( line = list( color = "black", width = 3 ), size = 16, color = "rgb(178,223,138)", symbol = "circle", opacity = 0.9 ), error_x = lis), error_y = lis), textfont = lis) ) trace5 <- list( uid = "f653d0", line = list( color = "", width = 0 ), name = "HT20", type = "scatter", x = c(-0.05800647, -0.05174312, -0.06917382, -0.06278965), y = c(0.1071245, 0.0822339, 0.06373747, 0.1062265), marker = list( line = list( color = "black", width = 3 ), size = 16, color = "rgb(115,193,80)", symbol = "circle", opacity = 0.9 ), error_x = lis), error_y = lis), textfont = lis) ) trace6 <- list( uid = "8045e8", line = list( color = "", width = 0 ), name = "HT22", type = "scatter", x = c(0.1019851, 0.09534021, 0.0832851, 0.1062007), y = c(0.07468498, 0.06731757, 0.1172952, 0.03836456), marker = list( line = list( color = "black", width = 3 ), size = 16, color = "rgb(51,160,44)", symbol = "circle", opacity = 0.9 ), error_x = lis), error_y = lis), textfont = lis) ) trace7 <- list( uid = "eb57e4", line = list( color = "", width = 0 ), name = "HT27", type = "scatter", x = c(-0.02251035, -0.01762548, -0.01399149, -0.009987589, -0.01960819, -0.02769381, -0.0205609, -0.02353862, -0.02974976), y = c(0.1113681, 0.1244515, 0.1211026, 0.1400648, 0.1057393, 0.1128777, 0.09368854, 0.1128864, 0.04781158), marker = list( line = list( color = "black", width = 3 ), size = 16, color = "rgb(151,157,99)", symbol = "circle", opacity = 0.9 ), error_x = lis), error_y = lis), textfont = lis) ) trace8 <- list( uid = "daa855", line = list( color = "", width = 0 ), name = "HT28", type = "scatter", x = c(0.09666203, 0.09268733, 0.09030964, 0.1075584, 0.08567151, 0.0898931, 0.09666203, 0.09268733, 0.09030964, 0.1075584), y = c(0.02999132, 0.0498491, 0.066603, 0.03246903, -0.03135056, 0.06054206, 0.02999132, 0.0498491, 0.066603, 0.03246903), marker = list( line = list( color = "black", width = 3 ), size = 16, color = "rgb(251,154,153)", symbol = "circle", opacity = 0.9 ), error_x = lis), error_y = lis), textfont = lis) ) trace9 <- list( uid = "8141d8", line = list( color = "", width = 0 ), name = "HT30", type = "scatter", x = c(-0.06509734, -0.06494372, -0.08067137, -0.06270091, -0.03518021, -0.08299951, -0.07570164, -0.1064576, -0.06322916), y = c(-0.04945242, 0.06573995, 0.07370412, 0.05268428, -0.03587492, 0.05973246, 0.08811882, 0.09473722, 0.06372659), marker = list( line = list( color = "black", width = 3 ), size = 16, color = "rgb(239,89,91)", symbol = "circle", opacity = 0.9 ), error_x = lis), error_y = lis), textfont = lis) ) trace10 <- list( uid = "0f0698", line = list( color = "", width = 0 ), name = "HT31", type = "scatter", x = c(0.1478522, 0.1376083, 0.1441146, 0.1392803, 0.1403174, 0.1438648, 0.1418454, 0.128618, 0.1053778), y = c(-0.0697895, -0.0177304, -0.0768396, -0.04160454, -0.04648636, -0.05136625, -0.09609146, -0.04948872, -0.03838844), marker = list( line = list( color = "black", width = 3 ), size = 16, color = "rgb(227,26,28)", symbol = "circle", opacity = 0.9 ), error_x = lis), error_y = lis), textfont = lis) ) trace11 <- list( uid = "abd7f9", line = list( color = "", width = 0 ), name = "HT34", type = "scatter", x = c(0.1862432, 0.2037513, 0.1753054, 0.2067631, 0.2016863, 0.1624851, 0.1387403, 0.2117341, 0.1815393), y = c(-0.08245619, -0.04599707, -0.05031403, -0.02717363, -0.03097138, -0.05963156, -0.1529083, -0.02725985, -0.04598003), marker = list( line = list( color = "black", width = 3 ), size = 16, color = "rgb(253,191,111)", symbol = "circle", opacity = 0.9 ), error_x = lis), error_y = lis), textfont = lis) ) trace12 <- list( uid = "e48986", line = list( color = "", width = 0 ), name = "HT35", type = "scatter", x = c(-0.08369773, -0.06086555, -0.1021769, -0.07153702, -0.05783174, -0.0609265, -0.02660314, -0.02330994, -0.1096888), y = c(-0.1974198, -0.2820493, -0.4344143, -0.1354647, -0.1314372, -0.2395455, -0.1229908, -0.2374365, -0.09766052), marker = list( line = list( color = "black", width = 3 ), size = 16, color = "rgb(255,159,56)", symbol = "circle", opacity = 0.9 ), error_x = lis), error_y = lis), textfont = lis) ) data <- list(trace1, trace2, trace3, trace4, trace5, trace6, trace7, trace8, trace9, trace10, trace11, trace12) layout <- list( font = list( size = 12, color = "#000", family = "'Open sans', verdana, arial, sans-serif" ), smith = FALSE, title = "Principal Components Analysis of the Spatial Statistics of alpha-beta Titanium Topology", width = 1296, xaxis = list( type = "linear", dtick = 0.05, range = c(-0.17334692222222223, 0.23200152222222223), tick0 = 0, ticks = "outside", title = "First Principal Components", anchor = "y", domain = c(0, 1), mirror = "all", nticks = 0, ticklen = 5, autotick = TRUE, position = 0, showgrid = TRUE, showline = TRUE, tickfont = list( size = 0, color = "", family = "" ), zeroline = TRUE, autorange = TRUE, gridcolor = "#ddd", gridwidth = 1, linecolor = "#000", linewidth = 1, rangemode = "normal", tickangle = "auto", tickcolor = "#000", tickwidth = 1, titlefont = list( size = 0, color = "", family = "" ), overlaying = FALSE, showexponent = "all", zerolinecolor = "#000", zerolinewidth = 1, exponentformat = "e", showticklabels = TRUE ), yaxis = list( type = "linear", dtick = 0.1, range = c(-0.46632980555555553, 0.17198030555555555), tick0 = 0, ticks = "outside", title = "Second Principal Components", anchor = "x", domain = c(0, 1), mirror = "all", nticks = 0, ticklen = 5, autotick = TRUE, position = 0, showgrid = TRUE, showline = TRUE, tickfont = list( size = 0, color = "", family = "" ), zeroline = TRUE, autorange = TRUE, gridcolor = "#ddd", gridwidth = 1, linecolor = "#000", linewidth = 1, rangemode = "normal", tickangle = "auto", tickcolor = "#000", tickwidth = 1, titlefont = list( size = 0, color = "", family = "" ), overlaying = FALSE, showexponent = "all", zerolinecolor = "#000", zerolinewidth = 1, exponentformat = "e", showticklabels = TRUE ), bargap = 0.2, boxgap = 0.3, height = 432, legend = list( x = 0.98, y = 0.98, font = list( size = 0, color = "", family = "" ), bgcolor = "#fff", xanchor = "auto", yanchor = "auto", traceorder = "normal", bordercolor = "#000", borderwidth = 1 ), margin = list( b = 80, l = 80, r = 80, t = 100, pad = 2, autoexpand = TRUE ), barmode = "stack", boxmode = "overlay", autosize = TRUE, dragmode = "zoom", hovermode = "x", titlefont = list( size = 0, color = "", family = "" ), separators = ".,", showlegend = TRUE, bargroupgap = 0, boxgroupgap = 0.3, hidesources = FALSE, plot_bgcolor = "#fff", paper_bgcolor = "#fff" ) p <- plot_ly() p <- add_trace(p, uid=trace1$uid, line=trace1$line, name=trace1$name, type=trace1$type, x=trace1$x, y=trace1$y, marker=trace1$marker, error_x=trace1$error_x, error_y=trace1$error_y, textfont=trace1$textfont) p <- add_trace(p, uid=trace2$uid, line=trace2$line, name=trace2$name, type=trace2$type, x=trace2$x, y=trace2$y, marker=trace2$marker, error_x=trace2$error_x, error_y=trace2$error_y, textfont=trace2$textfont) p <- add_trace(p, uid=trace3$uid, line=trace3$line, name=trace3$name, type=trace3$type, x=trace3$x, y=trace3$y, marker=trace3$marker, error_x=trace3$error_x, error_y=trace3$error_y, textfont=trace3$textfont) p <- add_trace(p, uid=trace4$uid, line=trace4$line, name=trace4$name, type=trace4$type, x=trace4$x, y=trace4$y, marker=trace4$marker, error_x=trace4$error_x, error_y=trace4$error_y, textfont=trace4$textfont) p <- add_trace(p, uid=trace5$uid, line=trace5$line, name=trace5$name, type=trace5$type, x=trace5$x, y=trace5$y, marker=trace5$marker, error_x=trace5$error_x, error_y=trace5$error_y, textfont=trace5$textfont) p <- add_trace(p, uid=trace6$uid, line=trace6$line, name=trace6$name, type=trace6$type, x=trace6$x, y=trace6$y, marker=trace6$marker, error_x=trace6$error_x, error_y=trace6$error_y, textfont=trace6$textfont) p <- add_trace(p, uid=trace7$uid, line=trace7$line, name=trace7$name, type=trace7$type, x=trace7$x, y=trace7$y, marker=trace7$marker, error_x=trace7$error_x, error_y=trace7$error_y, textfont=trace7$textfont) p <- add_trace(p, uid=trace8$uid, line=trace8$line, name=trace8$name, type=trace8$type, x=trace8$x, y=trace8$y, marker=trace8$marker, error_x=trace8$error_x, error_y=trace8$error_y, textfont=trace8$textfont) p <- add_trace(p, uid=trace9$uid, line=trace9$line, name=trace9$name, type=trace9$type, x=trace9$x, y=trace9$y, marker=trace9$marker, error_x=trace9$error_x, error_y=trace9$error_y, textfont=trace9$textfont) p <- add_trace(p, uid=trace10$uid, line=trace10$line, name=trace10$name, type=trace10$type, x=trace10$x, y=trace10$y, marker=trace10$marker, error_x=trace10$error_x, error_y=trace10$error_y, textfont=trace10$textfont) p <- add_trace(p, uid=trace11$uid, line=trace11$line, name=trace11$name, type=trace11$type, x=trace11$x, y=trace11$y, marker=trace11$marker, error_x=trace11$error_x, error_y=trace11$error_y, textfont=trace11$textfont) p <- add_trace(p, uid=trace12$uid, line=trace12$line, name=trace12$name, type=trace12$type, x=trace12$x, y=trace12$y, marker=trace12$marker, error_x=trace12$error_x, error_y=trace12$error_y, textfont=trace12$textfont) p <- layout(p, font=layout$font, smith=layout$smith, title=layout$title, width=layout$width, xaxis=layout$xaxis, yaxis=layout$yaxis, bargap=layout$bargap, boxgap=layout$boxgap, height=layout$height, legend=layout$legend, margin=layout$margin, barmode=layout$barmode, boxmode=layout$boxmode, autosize=layout$autosize, dragmode=layout$dragmode, hovermode=layout$hovermode, titlefont=layout$titlefont, separators=layout$separators, showlegend=layout$showlegend, bargroupgap=layout$bargroupgap, boxgroupgap=layout$boxgroupgap, hidesources=layout$hidesources, plot_bgcolor=layout$plot_bgcolor, paper_bgcolor=layout$paper_bgcolor)