You can use the symbol argument to set the mapping:
library(plotly)
DF <- data.frame(x = 1:40, y = 1:40, id = rep(LETTERS[1:4], each = 10))
plot_ly(DF, x = ~x, y = ~y, symbol = ~id, type = "scatter", mode = "markers")
# specify symbols:
# plot_ly(DF, x = ~x, y = ~y, symbol = ~id, symbols = as.character(seq_along(unique(DF$id))), type = "scatter", mode = "markers")
Also see schema() and navigate
object ► traces ► scatter ► attributes ► marker ► symbol ► values
The following displays all symbols currently available (modified version of this code)
vals <- schema(F)$traces$scatter$attributes$marker$symbol$values
vals <- grep("[a-z]", vals, value = TRUE)
grid_size <- ceiling(sqrt(length(vals)))
plot_ly() %>%
add_markers(
x = rep(seq_len(grid_size), each = grid_size, length.out = length(vals)),
y = rep(seq_len(grid_size), times = grid_size, length.out = length(vals)),
text = vals,
hoverinfo = "text",
marker = list(
symbol = vals,
size = 30,
line = list(
color = "black",
width = 2
)
)
)
