plotly / plotly/plotly.R

Bubble plot still ignores size constraints for singleton color categories

Open
#2,068 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
2.7k
Forks
641
PR merge metrics
No merged PRs in 30d

Description

As you can see in the following reprex, the sizing options get ignored for the singleton category (color == "D"); commit https://github.com/plotly/plotly.R/commit/306b4ef057631f9d3200fdfce636696bc0268952 seemed intended to fix this issue but it persists.

library(plotly)
library(dplyr)

dat = structure(list(color = c("A", "A", "A", "B", "B", "C", "C", "D"
), size = c(2L, 1L, 1L, 803L, 254L, 339L, 261L, 577L), x = c(0, 
0, 0, 32.9, 52, 20.4, 33.3, 73.7), y = c(0, 0, 0, 0.7, 0.8, 0.6, 
0, 0.2)), row.names = c(NA, -8L), class = c("tbl_df", "tbl", 
"data.frame"))

print(dat)

desired_maximum_marker_size = 10
sizeref <- 2 * max(dat$size) / (desired_maximum_marker_size^2)

plotly::plot_ly(
    data = dat,
    y = ~y,
    x = ~x,
    color = ~color,
    type = "scatter",
    mode = 'markers',
    sizes = c(1, desired_maximum_marker_size),
    marker = list(
      size = ~size,
      sizemin = 1,
      sizemax = 10,
      opacity = 0.7, 
      sizeref = sizeref,
      sizemode = 'area')
    
  )

newplot

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 supplied R reprex with plotly and confirm that the singleton color category ignores the marker sizing constraints. Trace how marker sizes are handled when a color category has one observation, then add a regression test covering that case. Done means the singleton category respects sizemin, sizemax, sizeref, and sizemode consistently with the other categories.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.