diff --git a/Modified Sequent Peak Algorithm (mSPA)/SPA.R b/Modified Sequent Peak Algorithm (mSPA)/SPA.R index 675c43048576e1777c0218371568c557651ff435..2b820bb938a7bffcd037320e93addbbc694b213c 100644 --- a/Modified Sequent Peak Algorithm (mSPA)/SPA.R +++ b/Modified Sequent Peak Algorithm (mSPA)/SPA.R @@ -1,27 +1,10 @@ -library("pacman") -library(hydroTSM) -library(reshape2) -pacman::p_load( - pacman, - dplyr, - GGally, - ggplot2, - ggthemes, - ggvis, - httr, - lubridate, - plotly, - rio, - rmarkdown, - shiny, - stringr, - tidyr -) +library(ggplot2) +library(readr) data <- readr::read_delim( file = "https://raw.githubusercontent.com/infohquan/link/master/inputdata_b.txt", - delim = "\t" + delim = "\t", col_names = c("inflow", "release", "precip", "evapo", "downstreamFlow") ) time <- @@ -43,11 +26,11 @@ year <- "%Y" )) n <- NROW(na.omit(data)) -Inflow <- data[, 1] -dem <- data[, 2] -prec <- data[, 3] -eva <- data[, 4] -netev <- (data[, 4] - data[, 3]) / 1000 +Inflow <- data$inflow +dem <- data$release +prec <- data$precip +eva <- data$evapo +netev <- (data$evapo - data$precip) / 1000 rule_curve <- c(34, 50, 63, 73, 77, 79, 80, 63, 46, 29, 12, 21) DS <- rep(8.5, 12) capacity <- rep(82.5, 12) @@ -155,7 +138,8 @@ result$Month = factor( result.gather <- gather(result, key = "Rule Curve", value = IndexValue, -Month) -ggplot(result.gather, +print( + ggplot2::ggplot(result.gather, aes(Month, IndexValue, group = `Rule Curve`, color = `Rule Curve`)) + ylim(0, 85) + geom_line(aes(y = IndexValue), lwd = 1.2) + @@ -164,3 +148,4 @@ ggplot(result.gather, x = "") + theme_few(base_size = 20) + scale_color_brewer(palette = "Set2") + theme(plot.title = element_text(hjust = 0.5)) +) \ No newline at end of file