Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Figure field is invalid when trying to send to API via R

I am trying to send a plotly plot that I made in R to my account, but I keep getting the following error:

Error: Client error: (400) Bad Request
	Figure field is invalid. Reason: Raw data arrays are not allowed at this endpoint. Use grid references instead. Raw data found at the following paths in the figure [('data', 0, u'marker', u'color'), ('data', 1, u'marker', u'color')]

The plotly plot looks good in RStudio. It just won’t push to my Plotly account.

The code:

pal <- c("grey10", "grey90")
ax <- list(
  title = "",
  zeroline = FALSE,
  showline = FALSE,
  showticklabels = FALSE,
  showgrid = FALSE
)

p <- plot_ly(data = df[1:115,], showlegend = FALSE) %>%
  add_trace(x = ~X1, y = ~`X2`, color = ~X2`, colors = pal, type='scatter', mode = 'lines', showlegend=FALSE) %>%
  layout(xaxis = ax, yaxis = ax, showlegend = FALSE)

api_create(x = p, filename = "plotname")

Thank-you for any suggestions.

1 Like

I have the exact same issue. Thanks for any help with this.

I have this problem too, keen to see new developments that solve this. Thanks.

I’ve opened an issue in the R repo. You can keep track of this issue here https://github.com/ropensci/plotly/issues/1021

1 Like

Should be fixed now. Please provide a reproducible example if you are still having problems.

I’m encountering this on my first use of Plot.ly as well. This is the first hit when you google for the error. Here’s the code I’m using:

# Plotly 3D heatmap plot
library(plotly)
Sys.setenv("plotly_username"="davidparks21")
Sys.setenv("plotly_api_key"="--------------------")

theta.grid = cbind(mu.grid, sigma.grid, nu.grid)
print(theta.grid)

p <- plot_ly(
  x = theta.grid[,1],
  y = theta.grid[,1],
  z = theta.grid[,1],
  type='scatter',
  mode='lines'
)

chart_link = api_create(p, filename="test_file")
chart_link

And the data looks like this:

> print(theta.grid)
       mu.grid sigma.grid   nu.grid
 [1,] 402.8942   2.439484 0.4227177
 [2,] 403.0096   2.544550 0.6381750
 [3,] 403.1249   2.649617 0.8536323
 [4,] 403.2403   2.754684 1.0690897
 [5,] 403.3556   2.859751 1.2845470
 [6,] 403.4710   2.964818 1.5000043
 [7,] 403.5863   3.069884 1.7154616
 [8,] 403.7017   3.174951 1.9309189
 [9,] 403.8170   3.280018 2.1463763
[10,] 403.9324   3.385085 2.3618336
[11,] 404.0477   3.490151 2.5772909
[12,] 404.1631   3.595218 2.7927482
[13,] 404.2784   3.700285 3.0082055
[14,] 404.3938   3.805352 3.2236629
[15,] 404.5091   3.910419 3.4391202
[16,] 404.6245   4.015485 3.6545775
[17,] 404.7398   4.120552 3.8700348
[18,] 404.8551   4.225619 4.0854921
[19,] 404.9705   4.330686 4.3009495
[20,] 405.0858   4.435752 4.5164068
[21,] 405.2012   4.540819 4.7318641
[22,] 405.3165   4.645886 4.9473214
[23,] 405.4319   4.750953 5.1627787
[24,] 405.5472   4.856020 5.3782361
[25,] 405.6626   4.961086 5.5936934

I think you want scatter3d not scatter