Я хочу создать пузырьковую диаграмму, используя следующие данные:
> head(data1)
# A tibble: 6 x 4
Group Group_Strength Group_N Group_Quality
<chr> <dbl> <dbl> <dbl>
1 Young Controls 1 1 18.5
2 Healthy Age-Matched Controls 59 59 20
3 Neurodegenerative Disease 36 178 19.1
4 Right Hemisphere Stroke 7.86 159 20.1
5 Left Hemisphere Stroke -19 19 15
6 Bilateral Stroke 26 26 17
Я хотел бы, чтобы размер каждого пузыря указывал столбец Group_N, цвет каждого пузыря указывал столбец Group_Strength, а ось Y - столбец Group_Quality.
До сих пор мне удалось представить столбец Group_N (размер пузыря) и столбец Group_strength (цвет), используя следующий код. Но я не могу понять, как изменить порядок пузырьков по оси Y, чтобы указать Group_Quality:
library(packcircles)
library(ggplot2)
library(tidyverse)
data1$Group_N <- as.numeric(data1$Group_N)
# Generate the layout. sizetype can be area or radius, following your preference on what to be proportional to value.
packing1 <- circleProgressiveLayout(data1$Group_N, sizetype='area')
data1 <- cbind(data1, packing1)
dat.gg1 <- circleLayoutVertices(packing1, npoints=50)
dat.gg1$Group_Strength <- rep(data1$Group_Strength, each=51)
# Plot
ggplot() +
# bubbles
geom_polygon(data = dat.gg1, aes(x, y, group = id, fill=Group_Strength), colour = "black", alpha = 0.6) +
scale_fill_distiller(palette = "BuPu", direction = 1 ) +
# text for each bubble
geom_text(data = data1, aes(x, y, size=Group_N, label = Group)) +
scale_size_continuous(range = c(1,4)) +
# Theme:
theme_void() +
theme(legend.position="none") +
coord_equal()
Дает мне следующую цифру:
Может ли кто-нибудь предложить способ представления Group_Quality по оси Y или каким-либо другим способом? Я в недоумении.
Данные
data1 <- structure(list(Group = c("Young Controls",
"Healthy Age-Matched Controls",
"Neurodegenerative Disease", "Right Hemisphere Stroke", "Left Hemisphere Stroke",
"Bilateral Stroke"), Group_Strength = c(1, 59, 36, 7.86, -19,
26), Group_N = c(1L, 59L, 178L, 159L, 19L, 26L), Group_Quality = c(18.5,
20, 19.1, 20.1, 15, 17)), class = "data.frame", row.names = c(NA,
-6L))