`add_annotations` incompatible with multicategory axis
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
I've been attempting to plot horizontal arrows using add_annotations in a plotly object with a multicategory y-axis. Instead of positioning annotations along the y-axis, they are all positioned at the origin.
(Because the same behavior occurs with other types of annotation, I have included some text in the reprex as well.)
library(tibble)
library(plotly)
#> Loading required package: ggplot2
#>
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#>
#> last_plot
#> The following object is masked from 'package:stats':
#>
#> filter
#> The following object is masked from 'package:graphics':
#>
#> layout
tribble(
~cat1, ~cat2, ~start, ~end,
"a", "f", 1, 2,
"a", "g", 2, 3,
"a", "h", 3, 0,
"b", "f", 0, 3
) %>%
plot_ly(y = ~list(cat1, cat2)) %>%
add_markers(x = ~start) %>%
add_markers(x = ~end) %>%
add_annotations(text = ":(",
showarrow = TRUE,
xref = "x", axref = "x",
yref = "y", ayref = "y",
x = ~start,
ax = ~end,
y = ~list(cat1, cat2),
ay = ~list(cat1, cat2))

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied R reprex and the add_annotations entry point, then trace how multicategory y-axis values are handled for annotations versus markers. Reproduce the origin positioning with the example and verify that annotations using list(cat1, cat2) are positioned along the multicategory axis without regressing other annotation types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100