Skip to content
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

Conversion of discrete labels fails if they come from a factor #1772

Closed
dmurdoch opened this issue May 19, 2020 · 0 comments · Fixed by #1773
Closed

Conversion of discrete labels fails if they come from a factor #1772

dmurdoch opened this issue May 19, 2020 · 0 comments · Fixed by #1773

Comments

@dmurdoch
Copy link
Contributor

This StackOverflow question https://stackoverflow.com/q/61888967/2554330 motivated this report.

If the labels in scale_x_discrete are a factor, ggplot works fine. This is okay:

ggplot(diamonds, aes(cut)) + 
  geom_bar() + 
  scale_x_discrete("Cut", labels=factor(letters[1:5]))

However, ggplotly() fails:

ggplotly(
  ggplot(diamonds, aes(cut)) + 
  geom_bar() + 
  scale_x_discrete("Cut", labels=factor(letters[1:5]))
)
#> Error in nchar(axisObj$ticktext): 'nchar()' requires a character vector

Apparently an as.character() call is needed when ticktext is constructed.

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

Successfully merging a pull request may close this issue.

1 participant