Colour legend is broken in scatterplot where only one value exists and a colorbar title is provided
Open
Nobody has claimed this yet.
bug
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
Example:
library(plotly)
df <- data.frame(x = 1:5, y = 1:5, col = c(1,1,1,1,1))
plot_ly(df, x = ~x, y = ~y, color = ~col) %>%
add_markers(marker = list(colorbar = list(title = "test")))
Result:

If any of the col values changes and it is no longer only 1's, then it works as expected. Also, if the title parameter is omitted, it also works as expected.
Here's the result when I omit the title:

This is using plotly 4.8.0 - latest on CRAN
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
Run the provided plotly R example with a constant col value and a colorbar title, then compare it with the versions where the title is omitted or col varies. Trace the behavior of the color legend and colorbar title, and consider the issue done when the constant-value scatterplot renders the title correctly without breaking the legend.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100