For a categorical colour aesthetic, there appears to be no documented way to use selectedpoints to select individual points.
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the plot_ly() documentation and the categorical-colour example to trace how colour creates separate traces and how selectedpoints is passed through. Done means providing a documented, consistent way to select points within each generated trace, with coverage for the shown example and the proposed R-style indexing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100