3D surface won't show data on plotly

36 Views Asked by At

I have been trying to plot my data (uploaded CSV file) on a 3D surface in plotly. The graph shows as empty (labels, title, legend etc all fine), is there anything missing from my code?

library(plotly)

Glaucoma_XYZ <- read.csv("~/Library/CloudStorage/SynologyDrive-Macbook/MSc Project/Glaucoma data XYZ CSV.csv")
View(Glaucoma_XYZ)
x <- as.matrix(Glaucoma_XYZ$Presenting.MD..dB.)
y <- as.matrix(Glaucoma_XYZ$Rate.of.progression..dB.year.)
z <- as.matrix(Glaucoma_XYZ$Risk.of.vision.loss)
plot <- plot_ly()
plot <- add_surface(p = plot, z = z)
plot <- layout(
  plot,
  title = list(text = "Risk of vision loss based on rate of visual field progression", 
  font = list(size = 12)),
  scene = list(
    xaxis = list(
      title = list(
        text = "Presenting MD (dB)", 
        font = list(size = 8)
      ), 
      range = c(min(-24.5), max(0.0))
    ),
    yaxis = list(
      title = list(
        text = "Rate of Progression (dB/year)", 
        font = list(size = 8)
      ), 
      range = c(min(-5.0), max(-0.5))
    ),
    zaxis = list(
      title = list(
        text = "Risk of Vision Loss", 
        font = list(size = 8)
      ), 
      range = c(min(0.0), max(10.0))
    )
  )
)
plot

I did load some other libraries earlier on, before creating and playing around with a heatmap and a scatterplot, which all plotted fine. Just this graph isn't showing the surface.

0

There are 0 best solutions below