Ваш код почти у цели, вы просто неправильно указали цветовую переменную.
(Кроме того, не * данные 1002 *, пожалуйста.)
library(ggplot2)
ggplot(Dataset, aes(specie, M1_sava)) +
facet_wrap(~ momento, nrow = 1) +
coord_flip() +
geom_col(aes(fill = as.numeric(specie))) +
scale_fill_gradient2(low = "white", high = "red") +
theme_bw(base_size = 10)
Данные в формате dput
.
Dataset <-
structure(list(specie = structure(c(26L, 25L, 24L, 23L, 22L,
21L, 20L, 19L, 18L, 17L, 16L, 15L, 14L, 13L, 12L, 11L, 10L, 9L,
8L, 7L, 6L, 5L, 4L, 3L, 2L, 1L, 26L, 25L, 24L, 23L, 22L, 21L,
20L, 19L, 18L, 17L, 16L, 15L, 14L, 13L, 12L, 11L, 10L, 9L, 8L,
7L, 6L, 5L, 4L, 3L, 2L, 1L, 26L, 25L, 24L, 23L, 22L, 21L, 20L,
19L, 18L, 17L, 16L, 15L, 14L, 13L, 12L, 11L, 10L, 9L, 8L, 7L,
6L, 5L, 4L, 3L, 2L, 1L, 26L, 25L, 24L, 23L, 22L, 21L, 20L, 19L,
18L, 17L, 16L, 15L, 14L, 13L, 12L, 11L, 10L, 9L, 8L, 7L, 6L,
5L, 4L, 3L, 2L, 1L), .Label = c("ar", "br", "cr", "dr", "er",
"fr", "Gr", "hr", "Ir", "jr", "kr", "lr", "mr", "nr", "or", "pr",
"qr", "rr", "sr", "tr", "ur", "vr", "wr", "xr", "yr", "zr"), class = "factor"),
momento = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L), .Label = c("M1", "M2", "M3", "M4"), class = "factor"),
M1_sava = c(1, 0.86, 1, 1, 1, 0.74, 0.39, 0.83, 0.83, 0,
0.7, 0.11, 1, 0, 0, 0, 0, 0.83, 0, 0, 0, 0, 0, 0.04, 0, 0,
0.33, 0.86, 0.39, 0.02, 0.07, 0.02, 0.87, 0.06, 0.63, 0.33,
0.91, 0.67, 0.18, 0.08, 0, 0, 0, 0, 0.08, 0, 0.04, 0, 0,
0, 0, 0, 0.04, 0.32, 0.02, 0, 0, 0, 0.96, 0.06, 0.18, 0.33,
0.63, 1, 0, 0.94, 0.17, 0, 0.41, 0.04, 0.44, 0.17, 0.02,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.89, 0, 0.03, 0.22, 0.41,
0.46, 0, 0.81, 0.39, 0.7, 0.7, 0, 0.87, 0.91, 0.33, 0.37,
0.24, 0.15, 0, 0)), class = "data.frame", row.names = c(NA,
-104L))