Create floating pie charts with ggplot
I am currently working on a floating pie chart report as one of the graphs. I am currently using the plotrix package to plot this pie chart. But since I am using ggplot2 for all other plots, the pie plot looks different. So I am trying to create a plot using ggplot2. I currently have two questions:
The ggplot plots are plotted on the polar coordination system. I want to plot some pie charts in a Cartesian coordinate system. I don't know how to do this at the moment.
I want to be able to control the radius of the pie in a cartesian coordinate system.
Here is the code I'm currently using:
library("plotrix") plot(1:5, type="n", xlab="x", ylab="y") floating.pie(2, 3, c(1,3,5), radius=0.5) floating.pie(4, 2, c(2,4), radius=0.2) floating.pie(4.5, 4, c(3,2,5,1), radius=0.3)
Thanks for your time and help.
source to share
Pie charts, by definition, use polar coordinates. You could overlay some pie charts on another graph that used Cartesian coordinates, but that would probably be awful. In fact, pie charts are terrible most of the time, so be careful what you want.
Example on the page
The important bit in this code indicates that the radius represents the "y" aesthetic.
df <- data.frame( variable = c("resembles", "does not resemble"), value = c(80, 20) ) ggplot(df, aes(x = "", y = value, fill = variable)) + geom_bar(width = 1, stat = "identity") + scale_fill_manual(values = c("red", "yellow")) + coord_polar("y", start = 2 * pi / 3) + ggtitle("Pac man")
source to share