Circular waffle chart (plum chart) in R

Hello,

I tried to find the tutorials for making a circular plot, that shows proportions of the whole, similar to this graphics: https://www.washingtonpost.com/graphics/2020/health/coronavirus-how-epidemics-spread-and-end/

But I couldn't find anything, it's not even mentioned anywhere.
So Do you know how can this kind of chart be made in R? And if it's impossible to do in R (which would be very strange), what program can be used to make it?

Is this close enough?

library(ggplot2)
library(dplyr)
DF <- expand.grid(-30:30, -30:30)
DF <- DF %>% mutate(R =sqrt(DF$Var1^2 + DF$Var2^2)) %>% 
  filter(R <= 30) %>% 
  mutate(COVID = sample(c("Recovered", "Dead"), 2821, replace = TRUE, prob = c(0.9, 0.1)))
ggplot(DF, aes(x = Var1, y = Var2, color = COVID)) + geom_point(size = 0.9) + coord_fixed()

Created on 2020-03-31 by the reprex package (v0.3.0)

4 Likes

Thank you very much!
This is exactly what is shown on the original graph. Although, the details are still esoteric for me. What is it exactly in your code that makes the graph circular?

The part of the code shown above uses the x and y values, called Var1 and Var2, to calculate the distance from each point to the origin, stores that result in a column called R, and then uses the filter function to keep only those points with a distance of 30 or less. The circle is the set of points that is less than 30 from the origin.

2 Likes

I better understand it now, thank you.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.