beautiful Pie Charts with R

前端 未结 4 1820
余生分开走
余生分开走 2020-12-07 13:34

Let\'s say I have this simple data:

 mydata <- data.frame(group=c(\"A\", \"B\", \"0\", \"AB\"), FR=c(20, 32, 32, 16))

If I want to creat

4条回答
  •  不思量自难忘°
    2020-12-07 14:01

    After a lot of trial and error, I have decided plotly works best:

    library(plotly)
    mydata <- data.frame(group=c("A", "B", "0", "AB"), FR=c(20, 32, 32, 16))
    
    q <- plot_ly(mydata, labels = ~group, values = ~FR, type = 'pie') %>%
      layout(title = "Title",          
             xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
             yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
    q
    
    

    This is a png, the original one in Rstudio is interactive when you hover over it.

提交回复
热议问题