plotly / plotly/plotly.R

Tooltip showing "NA" when facets variable has level with one obs

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

Tooltip shows "NA" instead of value when using facet_wrap/facet_grid with a categorical variable that has one level with only one observation. The tooltip for the level that has only one observation appears correct. But the tooltip for all other facets shows "NA". This issue occurs only when at least one of the levels of a categorical variable used in facet_wrap has exactly one observation. With two observations per level, the problem disappears.

library(plotly)

d <- data.frame(matrix(nrow = 100, ncol =0))

d$cat1 <- sample(LETTERS[1:4], 100, replace = TRUE, prob = c(0.1, 0.2, 0.65, 0.05))
d$x <- rnorm(100)

ggplotly(
  ggplot(data = d, aes(x = x)) +
    geom_histogram() +
    facet_wrap(cat1 ~ .)
)

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 reproducer using ggplotly with facet_wrap and a categorical level containing one observation. Trace how tooltip values are assigned across facets, then verify that the singleton level and all other facets display their expected values rather than "NA".

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.