plotly / plotly/plotly.R

plot_ly boxplot showing wrong x-axis

Open
#1,922 3 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

Suppose I have a list with three slots, but data for slots 2 and 3 are not yet available. When plotting a boxplot with just the first two slots, everything works as expected:

library(plotly)
y <- list("Group 1" = c(105,74,20), 
          "Group 2" = NA_real_, 
          "Group 3" = NA_real_)

boxplot <- plot_ly(type="box")

boxplot %>% 
  add_boxplot(x=y[[1]]) %>%
  add_boxplot(x=y[[2]])

image

But when trying to plot data for all three slots (where slots 2 and 3 don't have data), then the x-axis label is messed up and the data seems to be messed up as well. (I expected the boxplot to look exactly the same as the one above.)

boxplot %>% 
add_boxplot(x=y[[1]]) %>%
add_boxplot(x=y[[2]]) %>%
add_boxplot(x=y[[3]])

image

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

Start by running the issue's R reproduction with plot_ly(type="box") and successive add_boxplot(x=y[[...]] ) calls, comparing two traces with three. Trace how add_boxplot handles NA_real_ inputs and x-axis category assignment. Done means adding empty slots does not change the displayed data or x-axis label compared with the two-slot example.

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
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.