I would like to create geom_points whose area is filled in according to a proportion. Something like Harvey balls, although Harvey balls usually only map 0% 25% 50% 75% and 100% whereas in this case the fill could be anything from 0 to 100% e.g.
The geom_point doesn’t need to be a circle, it could be a bar whose area fills up in proportion to the frac as well. So long as the area fill is proportional to fraction it’ll work fine. e.g.
Reproducible data
library(tidyverse)
df <-
tibble(
x = c(1:5),
y = c(5:1),
yes = c(1, 14, 10, 42, 53),
total = c(11, 21, 25, 50, 100),
frac = yes/total)
df %>%
ggplot(
aes(
x = x,
y = y)) +
geom_point(
fill = "#000000",
size = 7.5)
>Solution :
You can take a look at geom_scatterpie:
library(scatterpie)
df %>%
ggplot(aes(x = x, y = y)) +
geom_scatterpie(data = df, cols = c("frac", "opp_frac"),
size = 1, pie_scale = 3) +
coord_equal()
data
df <-
tibble(
x = c(1:5),
y = c(5:1),
yes = c(1, 14, 10, 42, 53),
total = c(11, 21, 25, 50, 100),
frac = yes/total,
opp_frac = 1 - frac)



