# Get this figure: fig <- get_figure("jmareane", 225)
# Get this figure's data: data <- get_figure("jmareane", 225)$data
# Add data to this figure: p <- add_trace(p, x=c(4, 5), y=c(4, 5), kwargs=list(filename="politifact blog", fileopt="extend"))
# Get x data of first trace: x1 <- get_figure("jmareane", 225)$data[[1]]$x

# 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(
  x = c("Candidate", "Jeb Bush", "Ben Carson", "Chris Christie", "Ted Cruz", "Mike Huckabee", "John Kasich", "Rand Paul", "Marco Rubio", "Donald Trump", "Scott Walker", "Hilary Clinton", "Bernie Sanders", "Joe Biden"), 
  uid = "002f3f", 
  name = "Pants on fire", 
  type = "bar", 
  xsrc = "jmareane:226:b7e784", 
  ysrc = "jmareane:226:7762b6", 
  marker = list(
    line = list(
      color = "white", 
      width = 6
    ), 
    color = "rgb(0, 67, 88)"
  ), 
  error_x = list(copy_ystyle = TRUE), 
  error_y = list(
    color = "rgb(0, 67, 88)", 
    width = 1, 
    thickness = 1
  ), 
  opacity = 0.75, 
  visible = TRUE
)
trace2 <- list(
  x = c("Candidate", "Jeb Bush", "Ben Carson", "Chris Christie", "Ted Cruz", "Mike Huckabee", "John Kasich", "Rand Paul", "Marco Rubio", "Donald Trump", "Scott Walker", "Hilary Clinton", "Bernie Sanders", "Joe Biden"), 
  y = c("False %", "4", "67", "15", "32", "12", "12", "20", "15", "50", "26", "10", "17", "12"), 
  uid = "7d1243", 
  name = "False", 
  type = "bar", 
  xsrc = "jmareane:226:b7e784", 
  ysrc = "jmareane:226:982a3d", 
  marker = list(
    line = list(
      color = "white", 
      width = 6
    ), 
    color = "rgb(31, 138, 112)"
  ), 
  error_x = list(copy_ystyle = TRUE), 
  error_y = list(
    color = "rgb(31, 138, 112)", 
    width = 1, 
    thickness = 1
  ), 
  opacity = 0.75, 
  visible = TRUE
)
trace3 <- list(
  x = c("Candidate", "Jeb Bush", "Ben Carson", "Chris Christie", "Ted Cruz", "Mike Huckabee", "John Kasich", "Rand Paul", "Marco Rubio", "Donald Trump", "Scott Walker", "Hilary Clinton", "Bernie Sanders", "Joe Biden"), 
  y = c("Mostly False %", "26", "33", "9", "30", "26", "14", "10", "22", "13", "16", "17", "8", "14"), 
  uid = "d0c49e", 
  name = "Mostly False", 
  type = "bar", 
  xsrc = "jmareane:226:b7e784", 
  ysrc = "jmareane:226:24505c", 
  marker = list(
    line = list(
      color = "white", 
      width = 6
    ), 
    color = "rgb(190, 219, 57)"
  ), 
  error_x = list(copy_ystyle = TRUE), 
  error_y = list(
    color = "rgb(190, 219, 57)", 
    width = 1, 
    thickness = 1
  ), 
  opacity = 0.75, 
  visible = TRUE
)
trace4 <- list(
  x = c("Candidate", "Jeb Bush", "Ben Carson", "Chris Christie", "Ted Cruz", "Mike Huckabee", "John Kasich", "Rand Paul", "Marco Rubio", "Donald Trump", "Scott Walker", "Hilary Clinton", "Bernie Sanders", "Joe Biden"), 
  y = c("Half True %", "17", "0", "27", "14", "21", "18", "22", "21", "9", "18", "20", "21", "29"), 
  uid = "0daa7b", 
  name = "Half True", 
  type = "bar", 
  xsrc = "jmareane:226:b7e784", 
  ysrc = "jmareane:226:3891f0", 
  marker = list(
    line = list(
      color = "white", 
      width = 6
    ), 
    color = "rgb(255, 225, 26)"
  ), 
  error_x = list(copy_ystyle = TRUE), 
  error_y = list(
    color = "rgb(255, 225, 26)", 
    width = 1, 
    thickness = 1
  ), 
  opacity = 0.75
)
trace5 <- list(
  x = c("Candidate", "Jeb Bush", "Ben Carson", "Chris Christie", "Ted Cruz", "Mike Huckabee", "John Kasich", "Rand Paul", "Marco Rubio", "Donald Trump", "Scott Walker", "Hilary Clinton", "Bernie Sanders", "Joe Biden"), 
  y = c("Mostly True %", "28", "0", "20", "14", "9", "22", "20", "24", "6", "22", "19", "33", "20"), 
  uid = "002f9e", 
  name = "Mostly True", 
  type = "bar", 
  xsrc = "jmareane:226:b7e784", 
  ysrc = "jmareane:226:7becbc", 
  marker = list(
    line = list(
      color = "white", 
      width = 6
    ), 
    color = "rgb(253, 116, 0)"
  ), 
  error_x = list(copy_ystyle = TRUE), 
  error_y = list(
    color = "rgb(253, 116, 0)", 
    width = 1, 
    thickness = 1
  ), 
  opacity = 0.75, 
  visible = TRUE
)
trace6 <- list(
  x = c("Candidate", "Jeb Bush", "Ben Carson", "Chris Christie", "Ted Cruz", "Mike Huckabee", "John Kasich", "Rand Paul", "Marco Rubio", "Donald Trump", "Scott Walker", "Hilary Clinton", "Bernie Sanders", "Joe Biden"), 
  y = c("True %", "23", "0", "22", "2", "21", "29", "24", "17", "0", "11", "32", "21", "19"), 
  uid = "d05738", 
  name = "True.", 
  type = "bar", 
  xsrc = "jmareane:226:b7e784", 
  ysrc = "jmareane:226:92aa7c", 
  marker = list(
    line = list(
      color = "white", 
      width = 6
    ), 
    color = "rgb(166, 28, 0)"
  ), 
  error_x = list(copy_ystyle = TRUE), 
  error_y = list(
    color = "rgb(166, 28, 0)", 
    width = 1, 
    thickness = 1
  ), 
  opacity = 0.75
)
data <- list(trace1, trace2, trace3, trace4, trace5, trace6)
layout <- list(
  font = list(
    size = 10, 
    color = "rgb(105, 100, 124)", 
    family = "\"Droid Sans\", sans-serif"
  ), 
  width = 869, 
  xaxis = list(
    type = "category", 
    range = c(0.5, 20.5), 
    ticks = "inside", 
    title = "", 
    mirror = "allticks", 
    nticks = 22, 
    ticklen = 8, 
    showgrid = FALSE, 
    showline = TRUE, 
    tickfont = list(
      size = 10, 
      color = "black", 
      family = "\"Verdana\", monospace"
    ), 
    zeroline = FALSE, 
    autorange = TRUE, 
    gridcolor = "white", 
    gridwidth = 1, 
    linecolor = "rgb(34,34,34)", 
    linewidth = 1, 
    tickangle = -90, 
    tickcolor = "rgba(0, 0, 0, 0)", 
    titlefont = list(
      size = 12, 
      color = "black", 
      family = "\"Verdana\", monospace"
    ), 
    showexponent = "last", 
    zerolinewidth = 1, 
    showticklabels = TRUE
  ), 
  yaxis = list(
    type = "linear", 
    range = c(0, 106.3157894736842), 
    ticks = "inside", 
    title = "Proportion of Responses", 
    mirror = "allticks", 
    nticks = 5, 
    ticklen = 6, 
    showgrid = FALSE, 
    showline = TRUE, 
    tickfont = list(
      size = 10, 
      color = "black", 
      family = "\"Verdana\", monospace"
    ), 
    zeroline = FALSE, 
    autorange = TRUE, 
    gridcolor = "white", 
    gridwidth = 1, 
    linecolor = "rgb(34,34,34)", 
    linewidth = 1, 
    tickangle = -90, 
    tickcolor = "rgba(0, 0, 0, 0)", 
    titlefont = list(
      size = 12, 
      color = "black", 
      family = "\"Verdana\", monospace"
    ), 
    zerolinewidth = 1, 
    showticklabels = TRUE
  ), 
  bargap = 0.1, 
  height = 419, 
  legend = list(
    x = 1.0497131931166348, 
    y = 0.7824267782426779, 
    font = list(
      size = 12, 
      color = "rgb(105, 100, 124)", 
      family = "Arial, sans-serif"
    ), 
    xref = "paper", 
    yref = "paper", 
    bgcolor = "rgba(255, 255, 255, 0.5)", 
    xanchor = "center", 
    yanchor = "top", 
    traceorder = "reversed", 
    bordercolor = "rgb(207, 206, 202)", 
    borderwidth = 0
  ), 
  barmode = "stack", 
  autosize = TRUE, 
  titlefont = list(
    size = 11, 
    color = "rgb(88, 74, 77)", 
    family = "\"Courier New\", monospace"
  ), 
  showlegend = TRUE, 
  bargroupgap = 0.02, 
  plot_bgcolor = "white", 
  paper_bgcolor = "white"
)
p <- plot_ly()
p <- add_trace(p, x=trace1$x, uid=trace1$uid, name=trace1$name, type=trace1$type, xsrc=trace1$xsrc, ysrc=trace1$ysrc, marker=trace1$marker, error_x=trace1$error_x, error_y=trace1$error_y, opacity=trace1$opacity, visible=trace1$visible)
p <- add_trace(p, x=trace2$x, y=trace2$y, uid=trace2$uid, name=trace2$name, type=trace2$type, xsrc=trace2$xsrc, ysrc=trace2$ysrc, marker=trace2$marker, error_x=trace2$error_x, error_y=trace2$error_y, opacity=trace2$opacity, visible=trace2$visible)
p <- add_trace(p, x=trace3$x, y=trace3$y, uid=trace3$uid, name=trace3$name, type=trace3$type, xsrc=trace3$xsrc, ysrc=trace3$ysrc, marker=trace3$marker, error_x=trace3$error_x, error_y=trace3$error_y, opacity=trace3$opacity, visible=trace3$visible)
p <- add_trace(p, x=trace4$x, y=trace4$y, uid=trace4$uid, name=trace4$name, type=trace4$type, xsrc=trace4$xsrc, ysrc=trace4$ysrc, marker=trace4$marker, error_x=trace4$error_x, error_y=trace4$error_y, opacity=trace4$opacity)
p <- add_trace(p, x=trace5$x, y=trace5$y, uid=trace5$uid, name=trace5$name, type=trace5$type, xsrc=trace5$xsrc, ysrc=trace5$ysrc, marker=trace5$marker, error_x=trace5$error_x, error_y=trace5$error_y, opacity=trace5$opacity, visible=trace5$visible)
p <- add_trace(p, x=trace6$x, y=trace6$y, uid=trace6$uid, name=trace6$name, type=trace6$type, xsrc=trace6$xsrc, ysrc=trace6$ysrc, marker=trace6$marker, error_x=trace6$error_x, error_y=trace6$error_y, opacity=trace6$opacity)
p <- layout(p, font=layout$font, width=layout$width, xaxis=layout$xaxis, yaxis=layout$yaxis, bargap=layout$bargap, height=layout$height, legend=layout$legend, barmode=layout$barmode, autosize=layout$autosize, titlefont=layout$titlefont, showlegend=layout$showlegend, bargroupgap=layout$bargroupgap, plot_bgcolor=layout$plot_bgcolor, paper_bgcolor=layout$paper_bgcolor)