plotly / plotly/plotly.R

New since 4.9.3: add_annotations misaligns text when `x` or `y` are factors

Open
#1,931 0 comments 2 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

Hi,

when running the code below with plotly version 4.9.3,
the annotated text is not aligned to the respective cells.
With plotly version 4.9.2.1 however, it matches nicely.

#devtools::install_version("plotly", version="4.9.2.1")
library(plotly)

Grid <- expand.grid(x=1:3,y=4:6)
Grid <- cbind(Grid, z=rnorm(9))
Grid$xFac <- as.character(Grid$x)
Grid$yFac <- as.factor(Grid$y)

plot_ly(
  data=Grid,
  x=~xFac, y=~yFac, z=~z,
  type='heatmap') %>%
  add_annotations(
    text = letters[1:9], showarrow = FALSE)

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 provided R example with plotly 4.9.3 and compare its annotation alignment with 4.9.2.1, focusing on add_annotations with factor x and y values. Done means the annotated letters align with their heatmap cells in the affected version as they did previously.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.