Skip to content

wrapping of labels not supported in ggplotly #851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
earowang opened this issue Jan 18, 2017 · 2 comments
Closed

wrapping of labels not supported in ggplotly #851

earowang opened this issue Jan 18, 2017 · 2 comments

Comments

@earowang
Copy link

Hi Carson,

ggplot2 works fine for the wrapping of long labels, while ggplotly doesn't support yet. A little example is as follows:

library(plotly)
library(stringr)

df_x <- data.frame(
  x = "this is very loooooooooooong text to illustrate",
  y = 100
)

p <- ggplot(aes(x = x, y = y), data = df_x) +
  geom_bar(stat = "identity") +
  scale_x_discrete(labels = function(x) str_wrap(x, width = 10))
p
ggplotly(p)

Cheers,
Earo

cpsievert added a commit that referenced this issue Jan 23, 2017
@cpsievert
Copy link
Collaborator

Thanks @earowang. f85a9dd adds support for translating R linebreaks to HTML

For now, you'll need to manually adjust margins to account for the multiple lines of text (ggplotly()isn't that smart, yet)

ggplotly(p) %>% layout(margin = list(b = 100))

@earowang
Copy link
Author

Awesome! Thanks Carson.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants