Hi all!
I am just starting with plotly. I usually work with R and in this case I would like to convert a simple polar plot made with ggplot2 to plotly. I have tried with a toy example, but I get an error message I cannot solve. I would appreciate very much any hint.
This is my R code example:
library(ggplot2)
library(plotly)
kk <- data.frame(x = c(45, 90, 90, 180, 290),
y = c(1, 2, 5, 3, 4),
z = as.factor(c(1, 1, 1, 2, 2))
)
p <- ggplot(kk, aes(x = x, y = y, colour = z) ) +
geom_point() +
coord_polar(theta = "x", start = 0, direction = 1, clip = "on") +
scale_x_continuous(limits = c(0, 360),
breaks = (c(0, 90, 180, 270)))
p
p <- ggplotly(p)
p
With ggplot I obtain this plot:
but after “ggplotly”, I get the following error:
> p <- ggplotly(p)
Warning messages:
1: In min(z$x.range %||% z$x_range) :
ningún argumento finito para min; retornando Inf
2: In max(z$x.range %||% z$x_range) :
ningun argumento finito para max; retornando -Inf
3: In min(z$y.range %||% z$y_range) :
ningún argumento finito para min; retornando Inf
4: In max(z$y.range %||% z$y_range) :
ningun argumento finito para max; retornando -Inf
and the following plot:
Any hint?
Thanks, Pedro
PS: of course, I have seen another way of making polar coordinate scatterplots with plotly, but I would like to do it with ggplot because it is easier ( and shorter) to obtain colors for the different levels of a factor, and others…