Используя пакет scatterpie
, вы можете сгенерировать что-то похожее на то, что вы просили (масштабирование радиуса не идеально, но должно быть настраиваемым для получения желаемых результатов:
dat = structure(list(group = c("ave", "ave", "ave", "ave", "ave", "ave",
"ave", "ave", "ave", "ave", "ave", "ave", "ave", "ave", "ave",
"ave", "ave", "ave", "ave", "ave"), sp = c("A", "B", "C", "D",
"E", "F", "G", "H", "I", "J", "L", "M", "N", "O", "P", "Q", "R",
"S", "T", "U"), num = c(47L, 22L, 5L, 4L, 2L, 2L, 2L, 2L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), porc_rec = c(74.46808511,
22.72727273, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0), rec = c(35L, 5L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), pref = c(7L, 3L, 0L, 0L, 0L,
0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
ex = c(0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 1L, 1L, 1L)), class = "data.frame", row.names = c(NA,
-20L))
library(ggplot2)
library(scatterpie)
dat$idx = as.numeric(1:nrow(dat))
input = dat[,c("idx","num","porc_rec","ex","pref")]
input$recip = 100 - input$porc_rec
input$radius = abs(0.4 / scale((input$pref + 1)/ max(input$pref),center = 7))
ggplot() + geom_scatterpie(data=input, aes(x=idx, y=log(num),color = factor(ex), r = radius), cols=c("porc_rec","recip")) +
coord_equal() +
scale_fill_manual(values = c("black","white")) + scale_colour_manual(values = c("black","red"))
![enter image description here](https://i.stack.imgur.com/dQiJn.png)