Ah, awesome! thanks. One last question: I seem to be getting some kind of bleed-over from other arguments in a 3D scatterplot that I want to add this graph to. When my 3D scatter is by itself it looks great (code & plot below), and the surface plot by itself works great with your code (both below again). But doing them together completely screws up the colors… what’s going on here?
3D scatter:
plot_ly() %>%
add_trace(x = danc.x,
y = danc.y,
z = danc.z,
type = "scatter3d",
mode = "markers",
color = coh$dance,
colors = c("gray70", '#6d98f3'),
opacity = 1) %>%
add_trace(x = danc.x[which(coh$dance == 1)],
y = danc.y[which(coh$dance == 1)],
z = danc.z[which(coh$dance == 1)],
type = "scatter3d",
mode = "markers",
marker = list(color = "black", symbol = "circle-open")) %>%
add_trace(x = l1.x,
y = l1.y,
z = l1.z,
type = "scatter3d",
mode = "lines",
line = list(color = "black", width = 5, dash = 'dash')) %>%
layout(title = '"...used for dancing"',
scene = list(xaxis = list(title = 'India', range = c(1,6), ticktype = "array", tickvals = ticks),
yaxis = list(title = 'World', range = c(1,6), ticktype = "array", tickvals = ticks),
zaxis = list(title = 'USA', range = c(1,6), ticktype = "array", tickvals = ticks),
camera = list(eye = list(x = 2, y = -2, z = 1.25), zoom = 5),
showlegend = FALSE))
Simple surface plot:
plot_ly() %>% add_surface(x = 1:6,
y = 1:6,
z = dancplane.m,
type = "surface",
opacity = 1,
colors = c('#d1d1d1','#000000'))
Together, screwy colors…
danc <- plot_ly() %>%
add_surface(x = 1:6,
y = 1:6,
z = dancplane.m,
type = "surface",
opacity = 1,
colors = c('#d1d1d1','#000000')) %>%
add_trace(x = danc.x,
y = danc.y,
z = danc.z,
type = "scatter3d",
mode = "markers",
color = coh$dance,
colors = c("gray70", '#6d98f3'),
opacity = 1) %>%
add_trace(x = danc.x[which(coh$dance == 1)],
y = danc.y[which(coh$dance == 1)],
z = danc.z[which(coh$dance == 1)],
type = "scatter3d",
mode = "markers",
marker = list(color = "black", symbol = "circle-open")) %>%
add_trace(x = l1.x,
y = l1.y,
z = l1.z,
type = "scatter3d",
mode = "lines",
line = list(color = "black", width = 5, dash = 'dash')) %>%
layout(title = '"...used for dancing"',
scene = list(xaxis = list(title = 'India', range = c(1,6), ticktype = "array", tickvals = ticks),
yaxis = list(title = 'World', range = c(1,6), ticktype = "array", tickvals = ticks),
zaxis = list(title = 'USA', range = c(1,6), ticktype = "array", tickvals = ticks),
camera = list(eye = list(x = 2, y = -2, z = 1.25), zoom = 5),
showlegend = FALSE))