Closed
Description
Reprex:
library(ggplot2)
library(plotly)
p <- ggplot(iris, aes(Petal.Length, Sepal.Width, color = Species)) +
geom_point() +
xlab(element_blank())
ggplotly(p)
#> Error in if (nchar(axisTitleText) > 0) {: argument is of length zero
That seems to be happening here:
https://github.com/ropensci/plotly/blob/ebb017a6fbd1a582787017f98e8e40cb4f1431b3/R/ggplotly.R#L817
xlab("")
works, so the issue is definitely that nchar
of a theme element that is set to element_blank()
is NULL
. The same check happens a few lines later:
https://github.com/ropensci/plotly/blob/ebb017a6fbd1a582787017f98e8e40cb4f1431b3/R/ggplotly.R#L839
I get the same error when setting ylab
and ggtitle
to element_blank
, but not for setting the legend title to blank via theme(legend.title = element_blank())
.
I might be able to do a pretty minimal PR for this. The tests look reasonably straightforward.
Metadata
Metadata
Assignees
Labels
No labels