I am having trouble trying create the same ggplot pie chart in plotly, as I need plotly's interactive on-hover capability to view the details of a pie chart segment.
It appears plotly will render a gpplot piechart as a bar chart due to the presence of geom_bar
(my understanding).
I have the following code:
g2 <- ggplot( data = DT, aes( x = 1, y = percentage, fill = as.factor( operationtype ) ) ) +
geom_bar( width = 1, stat = "identity" ) +
facet_wrap( ~deviceid, ncol = 1 ) +
coord_polar(theta = "y", start=0) +
theme(axis.title.x = element_blank(),
axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.y = element_blank(),
axis.text.y = element_blank(),
axis.ticks.y = element_blank(),) +
labs( fill = "status" )
plot2 <- ggplotly(g2)
Where g2 is the ggplot piechart:
But after performing plot2 <- ggplotly(g2)
, plot2 becomes a bar chart:
How can render the same pie chart in plotly?