0

Known issue with surfaceaxis argument failing to respect margins and filling over line.

This has been asked before, so apologies if it's been answered or determined that it simply isn't possible (the last updates to the previous posts were >2y ago without a clear resolution).

Previous post: Plotly 3D filling under the line

Github discussion: https://github.com/plotly/plotly.py/issues/1206

My task is essentially the same as previous posts. I have a timeseries of several groups of lines that I have plotted using the scatter3d function of plot_ly. I would like to fill the area under each line, and it appears this is supported by the surfaceaxis=0 argument (0 indicating coloring by x-axis (along which the different groups are plotted).

Example code (same as prior):

library(plotly)

dens <- with(diamonds, tapply(price, INDEX = cut, density))
data <- data.frame(
  x = unlist(lapply(dens, "[[", "x")),
  y = unlist(lapply(dens, "[[", "y")),
  cut = rep(names(dens), each = length(dens[[1]]$x)))

p <- plot_ly(data, x = ~cut, y = ~x, z = ~y, type = 'scatter3d', mode = 'lines', color = ~cut)
p

Behavior:

enter image description here

Looking at the wonky behavior, it seems that the line being drawn looks from L to R on the x-axis looks for the next-higher value on the y-axis. Therefore, it gets confused when y-values decrease as you travel along the x-axis. I have no idea how to rectify this, but it seems like there really should be.

An acceptable alternative would be using a ridgeline density plot as suggested by a previous commenter, however, I'd really like to be able to use plotly to have an interactive and movable plot.

Thanks in advance for any thoughts!

0 Answers0