2021年4月23日星期五

ggplot multiple pie chart on one df not showing right ratio

I want to create multiple pie chart for a dataframe

      |header| value1 |value2|Functionality |  |:-----|:-------|:-----|:-------------|  |k1    |69918   |116345|Non Functional|  |k2    |12595   |51755 |Non Functional|  |k3    |10482   |14973 |Non Functional|  |k4    |53590   |115612|Non Functional|  |k5    |10531   |18635 |Non Functional|  |k6    |10406   |16838 |Non Functional|  |k7    |14159   |24417 |Non Functional|  |k8    |11913   |18754 |Non Functional|  |k9    |8844    |15266 |Non Functional|  |k1    |4101077 |3739815   |Functional|  |k2    |723353  |1440359   |Functional|  |k3    |617290  |377484    |Functional|  |k4    |1584932 |1598903   |Functional|  |k5    |811679  |776848    |Functional|  |k6    |692557  |633247    |Functional|  |k7    |903137  |878248    |Functional|  |k8    |742021  |695467    |Functional|  |k9    |380319  |363830    |Functional|  

I did the following following this guide: https://www.geeksforgeeks.org/create-multiple-pie-charts-using-ggplot2-in-r/

df$Germline <- factor(df$header)  df$Functionality <- factor(df$Functionality)    ggplot(data=df, aes(x=" ", y=value1, group=Functionality, colour=Functionality, fill=Functionality)) +           geom_bar(width = 1, stat = "identity") +           coord_polar("y", start=0) +            facet_grid(.~ header) +theme_void()  

But my results I am getting enter image description here

The value seems to be add up for all existing value instead of each individual header, what did I do wrong here and how do I fix it?

Thanks

https://stackoverflow.com/questions/67238459/ggplot-multiple-pie-chart-on-one-df-not-showing-right-ratio April 24, 2021 at 09:08AM

没有评论:

发表评论