Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Different marker shapes in 3d scatter plot

Is it possible to have different marker styles for different variables?

For example in the basic 3d scatterplot, automatic and manual are different colours but the same shape (circle):

mtcars$am[which(mtcars$am == 0)] <- 'Automatic’
mtcars$am[which(mtcars$am == 1)] <- 'Manual’
mtcars$am <- as.factor(mtcars$am)

p <- plot_ly(mtcars, x = ~wt, y = ~hp, z = ~qsec, color = ~am, colors = c(’#BF382A’, ‘#0C4B8E’)) %>%
add_markers() %>%
layout(scene = list(xaxis = list(title = ‘Weight’),
yaxis = list(title = ‘Gross horsepower’),
zaxis = list(title = ‘1/4 mile time’)))

Could automatic be a diamond and manual be a star?

Hey @Ellie_M,

You can always update traces with plotly_build():

p <- plotly_build(p)

p$x$data[[1]]$marker$symbol <- 'diamond'

Hi - thank you very much, that does exactly what I had hoped for.