I've been learning my way through ggplot2, and I've made it to using polar coordinates and making pie charts and I've run into a bit of trouble.
I want to make a pie chart that has no axis numbering or ticks. A sample of code I have that I thought should work is:
data = data.frame(Category = c("A", "B", "C", "D"), Value = runif(4))
ggplot(data, aes(0, weight = Value, fill = Category)) +
scale_x_continuous(breaks = NA) +
scale_y_continuous(breaks = NA) +
geom_bar(binwidth = 1) +
coord_polar(theta = "y") +
scale_fill_brewer(pal = "Set1")
This code gives me the error:
Error in if (ends_apart < 0.05) { : argument is of length zero
Omitting the breaks argument in the scale_y_continuous function results in a successful plot, except with numbering and tick marks on the radius of the pie chart. Omitting the coord_polar (and leaving the breaks argument in scale_y_continuous) function results in a stacked bar chart without x or y numbering or tick marks.
I've found some solutions that involve changing tick mark options, and those should be a fine workaround, but I was curious as to why I'm getting this error.
As a side note: I've uninstalled and reinstalled ggplot2 to ensure that I have the latest version and that the checksums all match up.
Edit: To clarify, what I'm after is something like:
except without the numbering on the pie chart.
pal
inscale_fill_brewer
, so I'm dubious that you have the latest version. – joran