First time using plotly, must objects/df's be rectangular?

Does a surface created in plotly have to come from a rectangular df? Can that data frame have NA's in it? I have a data set of elevation coordinates that is rhombohedral with NA's filling the space to make it rectangular. I would like to do something like this:

Exemplary Goal

library(plotly)
# volcano is a numeric matrix that ships with R
fig <- plot_ly(z = ~volcano)
fig <- fig %>% add_surface()

fig

Data

basin_data_plotly <- readr::read_csv("https://gitlab.com/Bryanrt-geophys/Thesis_GitHub/-/raw/nono_branch/data/wrangled/model_1/basin_data_plotly")

I tried removing my Y column (basin_data_plotly[ , -1]) but that did not seem to work. Any advice on how to make the something like the fallowing work?

Starting Point

library(plotly)
# volcano is a numeric matrix that ships with R
fig <- plot_ly(z = basin_data_plotly)
fig <- fig %>% add_surface()

fig

Hi @bryanrt,
Thanks for providing your data to play with. I couldn't get plotly to work unless I removed the "Y" column and converted to a matrix. It seems that NAs are not a problem.

library(plotly)
library(tidyverse)
basin_in <- readr::read_csv("https://gitlab.com/Bryanrt-geophys/Thesis_GitHub/-/raw/nono_branch/data/wrangled/model_1/basin_data_plotly")

basin_in %>% 
  select(-(Y)) %>%  
  as.matrix(.) -> basin

plot_ly(z = ~ basin, type="surface")

HTH

Thank you so much! I guess I was having issues with the way I was executing the plot_ly line as I had tried using the data after removing the Y column. Thank you kindly for the help!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.