plotly / plotly/plotly.R

Colour legend is broken in scatterplot where only one value exists and a colorbar title is provided

Open
#1,410 2 comments 0 reactions 0 assignees View on GitHub

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:

image

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:

image

This is using plotly 4.8.0 - latest on CRAN

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.