Функция geom_tile
помогает:
library(RColorBrewer)
col_strip <- brewer.pal(11, "RdBu")
library(ggplot2)
ggplot(df,
aes(x = date, y = 1, fill = Temp))+
geom_tile() +
scale_fill_gradientn(colors = rev(col_strip)) +
guides(fill = guide_colorbar(barwidth = 1)) +
theme_void()
Данные :
structure(list(date = structure(c(-32872, -32506, -32141, -31776,
-31411, -31045, -30680, -30315, -29950, -29584, -29219, -28854,
-28489, -28123, -27758, -27393, -27028, -26662, -26297, -25932,
-25567, -25202, -24837, -24472, -24107, -23741, -23376, -23011,
-22646, -22280, -21915, -21550, -21185, -20819, -20454, -20089,
-19724, -19358, -18993, -18628, -18263, -17897, -17532, -17167,
-16802, -16436, -16071, -15706, -15341, -14975, -14610, -14245,
-13880, -13514, -13149, -12784, -12419, -12053, -11688, -11323,
-10958, -10592, -10227, -9862, -9497, -9131, -8766, -8401, -8036,
-7670, -7305, -6940, -6575, -6209, -5844, -5479, -5114, -4748,
-4383, -4018, -3653, -3287, -2922, -2557, -2192, -1826, -1461,
-1096, -731, -365, 0, 365, 730, 1096, 1461, 1826, 2191, 2557,
2922, 3287, 3652, 4018, 4383, 4748, 5113, 5479, 5844, 6209, 6574,
6940, 7305, 7670, 8035, 8401, 8766, 9131, 9496, 9862, 10227,
10592, 10957, 11323, 11688, 12053, 12418, 12784, 13149, 13514,
13879, 14245, 14610, 14975, 15340, 15706, 16071, 16436, 16801,
17167, 17532), class = "Date"), Temp = c(15.16, 16.27, 15.17,
14.83, 15.26, 14.89, 15.26, 15.68, 14.99, 14.7, 14.99, 15.02,
15.74, 16.28, 15.2, 16.11, 15.75, 16.31, 16.04, 16.88, 15.85,
15.36, 15.18, 15.75, 15.68, 15.49, 15.82, 15.44, 15.92, 15.67,
15.64, 15.43, 15.61, 15.57, 15.54, 15.77, 15.81, 15.55, 15.64,
16.28, 16.03, 16.11, 15.91, 15.87, 15.55, 15.55, 17.01, 15.9,
15.74, 15.93, 15.9, 15.66, 15.02, 15.63, 14.53, 15.05, 15.25,
15.62, 15.8, 15.46, 16.02, 15.68, 15.58, 16.45, 16.1, 16.44,
15.82, 16.3, 16.68, 17, 16.11, 16.02, 16.41, 16.79, 16.25, 17.17,
15.78, 16.18, 16.31, 16.53, 16.78, NA, 16.13, 15.64, 16.4, 15.73,
16.44, 15.76, NA, NA, 16.33, 15.53, 15.32, 16.24, 15.98, 16.12,
15.95, 16.13, 16.41, 16.22, 16.65, 16.7, 16.74, 16.48, 16.12,
16.62, 16.38, 16.98, 16.7, 17.06, 17.3, 16.56, 16.39, 15.9, 16.62,
17.7, 16.61, 17.62, 17.12, 16.5, 16.77, 16.99, 16.6, 17.36, 17,
16.86, 17.48, 16.8, 16.8, 17.26, 17.09, 17.48, 16.85, 16.84,
17.16, 17.23, 17.59, 17.95, 17.12)), class = "data.frame", row.names = c(NA,
-139L))