Skip to content

ggplotly() does not adjust margin when axis labels are wrapped #1681

Open
@thomas-neitmann

Description

@thomas-neitmann
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)
})

newplot (6)

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

newplot (7)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions