Open
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)
})