Hi I really have googled this a lot without any joy. Would be happy to get a reference to a website if it exists. I'm struggling to understand the Hadley documentation on polar coordinates and I know that pie/donut charts are considered inherently evil.
That said, what I'm trying to do is
- Create a donut/ring chart (so a pie with an empty middle) like the tikz ring chart shown here
- Add a second layer circle on top (with
alpha=0.5
or so) that shows a second (comparable) variable.
Why? I'm looking to show financial information. The first ring is costs (broken down) and the second is total income. The idea is then to add + facet=period
for each review period to show the trend in both revenues and expenses and the growth in both.
Any thoughts would be most appreciated
Note: Completely arbitrarily if an MWE is needed if this was tried with
donut_data=iris[,2:4]
revenue_data=iris[,1]
facet=iris$Species
That would be similar to what I'm trying to do.. Thanks
I don't have a full answer to your question, but I can offer some code that may help get you started making ring plots using
ggplot2
.Thoughts:
iris
dataset (a good start), but I am unable to see how to use that data to make a ring plot. For example, the ring plot you have linked to shows proportions of several categories, but neitheriris[, 2:4]
noriris[, 1]
are categorical.geom_rect(data=dat2, xmax=3, xmin=2, aes(ymax=ymax, ymin=ymin))
period
, you can usefacet_wrap(~ period)
for facetting.ggplot2
most easily, you will want your data in 'long-form';melt()
from thereshape2
package may be useful for converting the data.ggplot(dat, aes(x=category, y=count, fill=category)) + geom_bar(stat="identity")
Just trying to solve question 2 with the same approach from bdemarest's answer. Also using his code as a scaffold. I added some tests to make it more complete but feel free to remove them.
And the result: