# Get this figure: fig <- get_figure("tcmoran", 47)
# Get this figure's data: data <- get_figure("tcmoran", 47)$data
# Add data to this figure: p <- add_trace(p, x=c(4, 5), y=c(4, 5), kwargs=list(filename="SWAPI-Spaceships", fileopt="extend"))
# Get y data of first trace: y1 <- get_figure("tcmoran", 47)$data[[1]]$y

# Get figure documentation: https://chart-studio.plotly.com/r/get-requests/
# Add data documentation: https://chart-studio.plotly.com/r/file-options/

# You can reproduce this figure in R with the following code!

# Learn about API authentication here: https://chart-studio.plotly.com/r/getting-started
# Find your api_key here: https://chart-studio.plotly.com/settings/api

library(plotly)
trace1 <- list(
  name = "Sentinel-class landing craft", 
  type = "scatter", 
  x = c(1000.0), 
  y = c(1.0), 
  marker = list(
    size = 20.0, 
    color = "rgb(13, 22, 104)"
  )
)
trace2 <- list(
  name = "Millennium Falcon", 
  type = "scatter", 
  x = c(1050.0), 
  y = c(0.5), 
  marker = list(
    size = 42.0, 
    color = "rgb(27, 230, 9)"
  )
)
trace3 <- list(
  name = "Y-wing", 
  type = "scatter", 
  x = c(1000.0), 
  y = c(1.0), 
  marker = list(
    size = 20.0, 
    color = "rgb(137, 85, 218)"
  )
)
trace4 <- list(
  name = "X-wing", 
  type = "scatter", 
  x = c(1050.0), 
  y = c(1.0), 
  marker = list(
    size = 21.0, 
    color = "rgb(40, 86, 85)"
  )
)
trace5 <- list(
  name = "TIE Advanced x1", 
  type = "scatter", 
  x = c(1200.0), 
  y = c(1.0), 
  marker = list(
    size = 24.0, 
    color = "rgb(62, 0, 111)"
  )
)
trace6 <- list(
  name = "Slave 1", 
  type = "scatter", 
  x = c(1000.0), 
  y = c(3.0), 
  marker = list(
    size = 6.666666666666666, 
    color = "rgb(22, 152, 17)"
  )
)
trace7 <- list(
  name = "Imperial shuttle", 
  type = "scatter", 
  x = c(850.0), 
  y = c(1.0), 
  marker = list(
    size = 17.0, 
    color = "rgb(80, 114, 231)"
  )
)
trace8 <- list(
  name = "EF76 Nebulon-B escort frigate", 
  type = "scatter", 
  x = c(800.0), 
  y = c(2.0), 
  marker = list(
    size = 8.0, 
    color = "rgb(23, 36, 202)"
  )
)
trace9 <- list(
  name = "A-wing", 
  type = "scatter", 
  x = c(1300.0), 
  y = c(1.0), 
  marker = list(
    size = 26.0, 
    color = "rgb(5, 233, 146)"
  )
)
trace10 <- list(
  name = "B-wing", 
  type = "scatter", 
  x = c(950.0), 
  y = c(2.0), 
  marker = list(
    size = 9.5, 
    color = "rgb(67, 214, 196)"
  )
)
trace11 <- list(
  name = "Republic Cruiser", 
  type = "scatter", 
  x = c(900.0), 
  y = c(2.0), 
  marker = list(
    size = 9.0, 
    color = "rgb(87, 205, 52)"
  )
)
trace12 <- list(
  name = "Naboo fighter", 
  type = "scatter", 
  x = c(1100.0), 
  y = c(1.0), 
  marker = list(
    size = 22.0, 
    color = "rgb(155, 134, 207)"
  )
)
trace13 <- list(
  name = "Naboo Royal Starship", 
  type = "scatter", 
  x = c(920.0), 
  y = c(1.8), 
  marker = list(
    size = 10.222222222222221, 
    color = "rgb(80, 101, 196)"
  )
)
trace14 <- list(
  name = "Scimitar", 
  type = "scatter", 
  x = c(1180.0), 
  y = c(1.5), 
  marker = list(
    size = 15.733333333333333, 
    color = "rgb(131, 175, 163)"
  )
)
trace15 <- list(
  name = "J-type diplomatic barge", 
  type = "scatter", 
  x = c(2000.0), 
  y = c(0.7), 
  marker = list(
    size = 57.142857142857146, 
    color = "rgb(170, 227, 124)"
  )
)
trace16 <- list(
  name = "Jedi starfighter", 
  type = "scatter", 
  x = c(1150.0), 
  y = c(1.0), 
  marker = list(
    size = 23.000000000000004, 
    color = "rgb(171, 95, 8)"
  )
)
trace17 <- list(
  name = "H-type Nubian yacht", 
  type = "scatter", 
  x = c(8000.0), 
  y = c(0.9), 
  marker = list(
    size = 177.77777777777777, 
    color = "rgb(193, 46, 209)"
  )
)
trace18 <- list(
  name = "Star Destroyer", 
  type = "scatter", 
  x = c(975.0), 
  y = c(2.0), 
  marker = list(
    size = 9.75, 
    color = "rgb(233, 168, 43)"
  )
)
trace19 <- list(
  name = "Trade Federation cruiser", 
  type = "scatter", 
  x = c(1050.0), 
  y = c(1.5), 
  marker = list(
    size = 14.000000000000002, 
    color = "rgb(86, 100, 18)"
  )
)
trace20 <- list(
  name = "Theta-class T-2c shuttle", 
  type = "scatter", 
  x = c(2000.0), 
  y = c(1.0), 
  marker = list(
    size = 40.0, 
    color = "rgb(116, 146, 86)"
  )
)
trace21 <- list(
  name = "Rebel transport", 
  type = "scatter", 
  x = c(650.0), 
  y = c(4.0), 
  marker = list(
    size = 3.25, 
    color = "rgb(48, 22, 160)"
  )
)
trace22 <- list(
  name = "Solar Sailer", 
  type = "scatter", 
  x = c(1600.0), 
  y = c(1.5), 
  marker = list(
    size = 21.333333333333332, 
    color = "rgb(3, 90, 58)"
  )
)
trace23 <- list(
  name = "Republic attack cruiser", 
  type = "scatter", 
  x = c(975.0), 
  y = c(1.0), 
  marker = list(
    size = 19.5, 
    color = "rgb(136, 185, 232)"
  )
)
trace24 <- list(
  name = "Naboo star skiff", 
  type = "scatter", 
  x = c(1050.0), 
  y = c(0.5), 
  marker = list(
    size = 42.0, 
    color = "rgb(163, 253, 246)"
  )
)
trace25 <- list(
  name = "Jedi Interceptor", 
  type = "scatter", 
  x = c(1500.0), 
  y = c(1.0), 
  marker = list(
    size = 30.0, 
    color = "rgb(161, 59, 123)"
  )
)
trace26 <- list(
  name = "arc-170", 
  type = "scatter", 
  x = c(1000.0), 
  y = c(1.0), 
  marker = list(
    size = 20.0, 
    color = "rgb(45, 253, 113)"
  )
)
trace27 <- list(
  name = "Belbullab-22 starfighter", 
  type = "scatter", 
  x = c(1100.0), 
  y = c(6.0), 
  marker = list(
    size = 3.666666666666667, 
    color = "rgb(192, 11, 34)"
  )
)
trace28 <- list(
  name = "V-wing", 
  type = "scatter", 
  x = c(1050.0), 
  y = c(1.0), 
  marker = list(
    size = 21.0, 
    color = "rgb(49, 65, 90)"
  )
)
trace29 <- list(
  name = "CR90 corvette", 
  type = "scatter", 
  x = c(950.0), 
  y = c(2.0), 
  marker = list(
    size = 9.5, 
    color = "rgb(69, 111, 107)"
  )
)
data <- list(trace1, trace2, trace3, trace4, trace5, trace6, trace7, trace8, trace9, trace10, trace11, trace12, trace13, trace14, trace15, trace16, trace17, trace18, trace19, trace20, trace21, trace22, trace23, trace24, trace25, trace26, trace27, trace28, trace29)
layout <- list(
  title = "Star Wars API - Spaceships", 
  xaxis = list(
    type = "log", 
    tick0 = -1, 
    title = "Max. atmosphering speed [km/h]", 
    showgrid = TRUE, 
    zeroline = FALSE
  ), 
  yaxis = list(
    title = "Hyperdrive rating", 
    showgrid = TRUE, 
    zeroline = FALSE
  ), 
  showlegend = FALSE
)
p <- plot_ly()
p <- add_trace(p, name=trace1$name, type=trace1$type, x=trace1$x, y=trace1$y, marker=trace1$marker)
p <- add_trace(p, name=trace2$name, type=trace2$type, x=trace2$x, y=trace2$y, marker=trace2$marker)
p <- add_trace(p, name=trace3$name, type=trace3$type, x=trace3$x, y=trace3$y, marker=trace3$marker)
p <- add_trace(p, name=trace4$name, type=trace4$type, x=trace4$x, y=trace4$y, marker=trace4$marker)
p <- add_trace(p, name=trace5$name, type=trace5$type, x=trace5$x, y=trace5$y, marker=trace5$marker)
p <- add_trace(p, name=trace6$name, type=trace6$type, x=trace6$x, y=trace6$y, marker=trace6$marker)
p <- add_trace(p, name=trace7$name, type=trace7$type, x=trace7$x, y=trace7$y, marker=trace7$marker)
p <- add_trace(p, name=trace8$name, type=trace8$type, x=trace8$x, y=trace8$y, marker=trace8$marker)
p <- add_trace(p, name=trace9$name, type=trace9$type, x=trace9$x, y=trace9$y, marker=trace9$marker)
p <- add_trace(p, name=trace10$name, type=trace10$type, x=trace10$x, y=trace10$y, marker=trace10$marker)
p <- add_trace(p, name=trace11$name, type=trace11$type, x=trace11$x, y=trace11$y, marker=trace11$marker)
p <- add_trace(p, name=trace12$name, type=trace12$type, x=trace12$x, y=trace12$y, marker=trace12$marker)
p <- add_trace(p, name=trace13$name, type=trace13$type, x=trace13$x, y=trace13$y, marker=trace13$marker)
p <- add_trace(p, name=trace14$name, type=trace14$type, x=trace14$x, y=trace14$y, marker=trace14$marker)
p <- add_trace(p, name=trace15$name, type=trace15$type, x=trace15$x, y=trace15$y, marker=trace15$marker)
p <- add_trace(p, name=trace16$name, type=trace16$type, x=trace16$x, y=trace16$y, marker=trace16$marker)
p <- add_trace(p, name=trace17$name, type=trace17$type, x=trace17$x, y=trace17$y, marker=trace17$marker)
p <- add_trace(p, name=trace18$name, type=trace18$type, x=trace18$x, y=trace18$y, marker=trace18$marker)
p <- add_trace(p, name=trace19$name, type=trace19$type, x=trace19$x, y=trace19$y, marker=trace19$marker)
p <- add_trace(p, name=trace20$name, type=trace20$type, x=trace20$x, y=trace20$y, marker=trace20$marker)
p <- add_trace(p, name=trace21$name, type=trace21$type, x=trace21$x, y=trace21$y, marker=trace21$marker)
p <- add_trace(p, name=trace22$name, type=trace22$type, x=trace22$x, y=trace22$y, marker=trace22$marker)
p <- add_trace(p, name=trace23$name, type=trace23$type, x=trace23$x, y=trace23$y, marker=trace23$marker)
p <- add_trace(p, name=trace24$name, type=trace24$type, x=trace24$x, y=trace24$y, marker=trace24$marker)
p <- add_trace(p, name=trace25$name, type=trace25$type, x=trace25$x, y=trace25$y, marker=trace25$marker)
p <- add_trace(p, name=trace26$name, type=trace26$type, x=trace26$x, y=trace26$y, marker=trace26$marker)
p <- add_trace(p, name=trace27$name, type=trace27$type, x=trace27$x, y=trace27$y, marker=trace27$marker)
p <- add_trace(p, name=trace28$name, type=trace28$type, x=trace28$x, y=trace28$y, marker=trace28$marker)
p <- add_trace(p, name=trace29$name, type=trace29$type, x=trace29$x, y=trace29$y, marker=trace29$marker)
p <- layout(p, title=layout$title, xaxis=layout$xaxis, yaxis=layout$yaxis, showlegend=layout$showlegend)