ggplotly() does not adjust margin when axis labels are wrapped
Open
Nobody has claimed this yet.
bug
ggplotly
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
library(ggplot2)
library(plotly)
df <- data.frame(
a = "A very long label that needs to be wrapped",
b = 10,
c = "A very long label<br>that needs<br>to be wrapped"
)
wrap <- function(x) stringr::str_wrap(x, 10)
ggplotly({
ggplot(df, aes(a, b)) +
geom_col() +
coord_flip() +
scale_x_discrete(labels = wrap)
})

ggplotly({
ggplot(df, aes(c, b)) +
geom_col() +
coord_flip() +
scale_x_discrete(labels = wrap)
})

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
Run the supplied R reproduction through ggplotly() first. Then trace the axis-label and margin conversion path; no source file or test is named in the issue, so use existing ggplotly tests if present. Done means wrapped labels, including
labels, have sufficient margin and remain legible.
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
- 35/100