# Get this figure: fig <- get_figure("MattSundquist", 13137)
# Get this figure's data: data <- get_figure("MattSundquist", 13137)$data
# Add data to this figure: p <- add_trace(p, x=c(4, 5), y=c(4, 5), kwargs=list(filename="Division of Work in a Typical Workweek", fileopt="extend"))
# Get y data of first trace: y1 <- get_figure("MattSundquist", 13137)$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 = "e7075d",
name = "Col2_% of Average Workweek, trace1_y, trace2_y",
type = "bar",
x = c("14", "19", "28", "39"),
y = c("Searching and
Gathering Information", "Communicating and
collaborating internally", "Reading and Answering Email", "Completing Tasks"),
orientation = "h"
)
data <- list(trace1)
layout <- list(
title = "Division of Work in a Typical Workweek",
width = 592,
xaxis = list(
type = "linear",
range = c(0, 41.05263157894737),
zeroline = FALSE,
autorange = TRUE,
ticksuffix = "%"
),
yaxis = list(
type = "category",
range = c(-0.5, 3.5),
title = "",
zeroline = FALSE,
autorange = TRUE
),
height = 433,
margin = list(l = 200),
autosize = TRUE,
showlegend = FALSE
)
p <- plot_ly()
p <- add_trace(p, uid=trace1$uid, name=trace1$name, type=trace1$type, x=trace1$x, y=trace1$y, orientation=trace1$orientation)
p <- layout(p, title=layout$title, width=layout$width, xaxis=layout$xaxis, yaxis=layout$yaxis, height=layout$height, margin=layout$margin, autosize=layout$autosize, showlegend=layout$showlegend)