Having a dataframe with columns of date, time and the value.
date time value
1 28.02. 15:19 14.63
2 28.02. 15:30 16.11
3 28.02. 15:41 78.47
4 28.02. 15:51 13.42
5 01.03. 08:12 15.46
6 01.03. 08:23 14.66
7 01.03. 08:34 14.14
8 01.03. 08:45 13.52
I want a barchart with a bar for every row. On the x-axis the date should be shown, but summarized for the areas where bars of a date are shown. These areas should be seperated with an vertical line. The time only should be shown on peak bars. High peaks can be defined as >2*mean(value).
I tried the following. The vline is manually added at that point where the date changes in the dataframe. When i set x to the date column, the bars will be aggregated for the whole date, so i set it to the index.
p = ggplot(test, aes(x=1:nrow(test), y = value)) +
geom_col(fill="#b0bdc7") +
labs(y="Seconds", x="Run") +
theme_minimal() +
theme(panel.grid.major.x = element_blank(), panel.grid.minor.x = element_blank()) +
geom_hline(aes(yintercept = median(value), color ="#eb6619")) +
theme(legend.position="none") +
coord_cartesian(ylim = c(0, 50)) +
scale_y_continuous(breaks= c(10,20,30,40,50)) +
geom_vline(aes(xintercept = 5.5), linetype=2, color="#494856")