I understand that there is how to plot datetime variables with geom_area. I tried to convert first to a factor, then to a numeric, however i got this error every time:
Warning message: In max(ids, na.rm = TRUE) : no non-missing arguments to max; returning -Inf
If there is anyone who can help me i would really appreciate it!
My date time variable is: "POSIXct" "POSIXt" and the other numeric.
My data:
'data.frame': 96 obs. of 2 variables:
$ Date..GMT. : POSIXct, format: "1966-02-20 00:00:00" "1966-02-20 01:00:00" "1966-02-20 02:00:00" ...
$ Significant.Wave.Height.m.: num 3.04 3 2.98 2.97 2.97 3 3.03 3.08 3.14 3.21 ...
My code:
df1 %>% ggplot(aes(x = Date..GMT., y = Significant.Wave.Height.m.)) +
geom_line(size = 1, color = "#80A0C7") +
geom_area(fill = "#80A0C7") +
scale_y_continuous(breaks = seq(0, 7, 2),
limits = c(min_SigHeight, 7)) +
scale_x_datetime(labels = date_format("%d-%b"), date_breaks = "1 day") +
theme(panel.grid.major = element_line(size = 0.7, colour = '#D6E7EF'),
panel.background = element_rect(fill='white'),
panel.grid.minor = element_blank(),
axis.title.y = element_text(size = 20, color = "#80A0C7"),
axis.text.y = element_text(size = 24, color = "#80A0C7"),
panel.border = element_rect(colour = "black", fill=NA),
axis.text.x.bottom = element_text(angle = 30, color = "black", size = 24)) +
labs(y = expression(H[m0] (m)), x = "")