您可以使用
library(tidyverse)
df %>%
pivot_longer(-algorithms) %>%
ggplot(aes(x = algorithms, y = value, fill = name)) +
geom_col()
或者
df %>%
pivot_longer(-algorithms) %>%
ggplot(aes(x = algorithms, y = value, fill = name)) +
geom_col(position = position_dodge())
用于刻面绘图
df %>%
pivot_longer(-algorithms) %>%
ggplot(aes(x = algorithms, y = value)) +
geom_col(position = position_dodge()) +
facet_wrap(name~.)
数据
df = structure(list(algorithms = c("Alg_1", "Alg_2", "Alg_3", "Alg_4",
"Alg_5"), Question_1 = c(51L, 43L, 48L, 48L, 54L), Question_2 = c(49L,
35L, 53L, 39L, 63L), Question_3 = c(55L, 42L, 54L, 48L, 47L),
Question_4 = c(52L, 36L, 46L, 48L, 55L)), class = "data.frame", row.names = c(NA,
-5L))