Commit f40cb6b0 authored by Quan-Van Dau's avatar Quan-Van Dau
Browse files

plot for shiny

parent f80545ce
#' Analysis
#' Input data must begins with the year 2000
#' @param data data or vector
#' @param x number of synthetic years
#' @param n specific data column
shinyplot <- function(optStorage, n , Max) {
ggplot(optStorage, aes(Date, Storage , fill = Period)) +
geom_area(position = "identity", alpha = 0.88) +
geom_rect(aes(
xmin = as.Date("2000-01-01", "%Y-%m-%d"),
xmax = as.Date("2000-12-30", "%Y-%m-%d"),
ymin = 0,
ymax = Min[1, n],
fill = "DS"
)) +
geom_smooth(
method = 'loess' ,
formula = 'y ~ x',
span = 0.1,
alpha = 0.5,
se = T,
lwd = 0.2
) +
scale_x_date(labels = date_format("%b"), date_breaks = "1 month") +
ggtitle(paste0(reservoir[n], " Reservoir")) + xlab("") + ylab("Storage (MCM)") +
theme_few(base_size = 13) +
ylim(0, 370) +
theme(plot.title = element_text(hjust = 0.5)) +
geom_hline(
yintercept = Max[1, n],
color = "red",
linetype = "dashed",
lwd = 0.4
)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment