0

Is there a simple way of using coord_polar() when doing a barplot in ggplot2 using plotly?

Example without using polar coordinates - It works

One could also add +coord_flip() and this would still work.

library(ggplot2)
library(plotly)
# Create fake data
df <- data.frame(
           genre=c("Pop", "HipHop", "Latin", "Pop", "Pop", "HipHop"), 
           artist=c("ArianaGrande", "ChrisBrown", "DaddyYankee", "EdSheeran", 
                    "LewisCapaldi", "ShawnMendes")
      )
# Create a ggplot bar plot in polar coordinates
p <- ggplot(data=df) + 
      geom_bar(aes(x=genre, fill=artist))
# Wrap it around plotly
ggplotly(p)

plotly

What I need

When we add coord_polar() it stops working. Is there a workaround? I get the following messages

Warning messages:
1: In min(z[["x"]]$dimension %()% z$x.range %||% z$x_range) :
  no non-missing arguments to min; returning Inf
2: In max(z[["x"]]$dimension %()% z$x.range %||% z$x_range) :
  no non-missing arguments to max; returning -Inf
3: In min(z[["y"]]$dimension %()% z$y.range %||% z$y_range) :
  no non-missing arguments to min; returning Inf
4: In max(z[["y"]]$dimension %()% z$y.range %||% z$y_range) :
  no non-missing arguments to max; returning -Inf
Euler_Salter
  • 3,271
  • 8
  • 33
  • 74

0 Answers0