Skip to content

For a categorical colour aesthetic, there appears to be no documented way to use selectedpoints to select individual points. #2459

@krivit

Description

@krivit

The following example highlights the first point from each colour group (the first "a" point and the first "b" point):

library(plotly)

d <- data.frame(x = 1:4, c = c("a", "a", "b", "b"))

plot_ly(d) |>
  add_trace(x=~x, y = ~x, color = ~c, type = "scatter", selectedpoints = list(0))

From the plot_ly() documentation, it appears that this code implicitly creates multiple traces, one for each colour, so this behaviour makes sense on this level (even if it's surprising). However, there appears to be no documented way to access individual traces. I've tried a number of permutations

In my opinion, if the code is going to transparently create multiple traces like that, it should also transparently map selectedpoints provided by the user (ideally as 1-based indexes or logical vectors, for consistency with R) to their positions within each trace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions