Black Lives Matter. Please consider donating to Black Girls Code today.
Dash Enterprise delivers an incredible 21x cost savings 💸Download the e-book!

Plot_ly extract traces

Once you have created a plotly plot in R via:

stable_plot <- plot_ly(calcRelAnchorTest(input$anchor_nodeTest),x=~get(x_label), y=~get(y_label), type=‘scatter’, mode=‘markers+lines’, name=input$anchor_nodeTest)

Is it possible to extract the traces from the “stable_plot” object? Is there a definition for what this object contains or perhaps another way to go about doing this?

I just want to change the graph’s x and y axis but get data for the new graph using the trace previously used. Thus, I need a way to extract the current traces in the plot.

Thanks!

Prateek

Hey @prateek.mohan1

To look at what it contains use plotly_json(p)

You can use plotly_build() so something like:

p <- plotly_build()
p$x$data[[1]]$x

You can modify other attributes of the trace with the style() function too https://plot.ly/ggplot2/user-guide/#modify-with-style

or if you mean from an online graph you can use get requests https://plot.ly/r/get-requests/

Thanks bcd, that’s perfect! I’ll look through this structure for the data that I need.