Open schuemie opened 2 years ago
Pro tip, search if the issue exists before wasting time on a reprex π. I would add that this is an especially prevalent bug since the default is to render 3D bubbles and apply transparency when using the size argument.
library(plotly)
d<-rbind(
data.frame(x=3,y=3,z=3,g='A')
,data.frame(x=2,y=2,z=2,g='B')
,data.frame(x=1,y=1,z=1,g='C')
)
p<-plot_ly(d,x=~x,y=~y,z=~z,color=~g,size=~I(pi*1000*(3:1)^2))
# Fine
p %>% add_markers(marker=list(opacity=1))
# Far points render in front of near points
p %>% add_markers(marker=list(opacity=.99))
Created on 2022-01-31 by the reprex package (v2.0.1)
cross referencing an issue on the js repo https://github.com/plotly/plotly.js/issues/1267
When creating a 3D scatter plot, the dots should be drawn in the order of depth, so drawing the furthest dot first, to get the right occlusion. This works well when alpha = 1, but when alpha < 1 the dots seem to be drawn in order of categories instead.
Here's a simple example. If you rotate it so the green dot is at the forefront, it is nevertheless occluded by the blue dot:
This especially problematic when you have a lot of dots, and a cluster of nearby dots is completely hidden by a faraway cluster of dots of a different color.