Changed the linetypes to dotted for observed data
Added a legend under both plots
Changed the page headings to include Gage location and removed the run type and number
Observed lines are dashed and legend added to both graphs: bdfd937ae59462895b450aa258fd8cdfc65f134d
Changed the title: 677d72554b81c1239769f60a537bf1a34ecb2265
Changed the linetypes to dotted for observed data Added a legend under both plots Changed the page headings to include Gage location and removed the run type and number
function (plot_number, hydrograph_df, hg_plot_pages) { plot_df <- dplyr::filter(hg_plot_pages, plot == plot_number) plot <- plot_df$plot run_type <- as.character(plot_df$Run_type) run_num <- as.numeric(as.character(plot_df$Run_num)) river_sta <- as.numeric(as.character(plot_df$River_Sta)) hg_df_plot <- dplyr::filter(hydrograph_df, River_Sta == river_sta, Run_type == run_type, Run_num == run_num)
ws <- dplyr::filter(hg_df_plot, Type == "Obs_WS" | Type == "WS_Elev") q <- dplyr::filter(hg_df_plot, Type == "Obs_Q" | Type == "Model_Q")
WS_cols <- c(WS_Elev = "darkslategray4", Obs_WS = "coral3") WS_line <- c(WS_Elev = "solid", Obs_WS = "dashed")
Discharge_cols <- c(Model_Q = "darkslategray4", Obs_Q = "coral3") Discharge_line <- c(Model_Q = "solid", Obs_Q = "dashed")
WS_labels <- c(WS_Elev = "Modeled", Obs_WS = "Observed") Discharge_labels <- c(Model_Q = "Modeled", Obs_Q = "Observed")
ws_plot <- ggplot(data = ws, aes(x = date, y = value, color = Type), na.rm = TRUE) + geom_line(aes(linetype=Type) ,size = 1) + facet_grid(. ~ Event, scales = "free") + theme_bw() + scale_color_manual(values = WS_cols, labels = WS_labels) + scale_linetype_manual(values = WS_line, labels = WS_labels ) + theme(legend.position = "bottom", legend.title = element_blank(), axis.title.x = element_blank(), axis.text.x = element_text(angle = 50, hjust = 1)) + scale_x_datetime(date_labels = "%e %b", date_breaks = "7 days", date_minor_breaks = "1 day") + labs(y = "Elevation (NAVD88 feet)")
q_plot <- ggplot(data = q, aes(x = date, y = value/1000, color = Type), na.rm = TRUE) + geom_line(aes(linetype=Type) ,size = 1) + facet_grid(. ~ Event, scales = "free") + theme_bw() + scale_color_manual(values = Discharge_cols, labels = Discharge_labels) + scale_linetype_manual(values = Discharge_line, labels = Discharge_labels) + theme(legend.position = "bottom", legend.title = element_blank(), axis.title.x = element_blank(), axis.text.x = element_text(angle = 50,hjust = 1)) + scale_x_datetime(date_labels = "%e %b", date_breaks = "7 days", date_minor_breaks = "1 day") + labs(y = "Discharge (1000 cubic feet per second)")
removed from title - ws$Run_type,"#", ws$Run_num,
title <-textGrob(label = paste(trimws(ws$River), "River,", trimws(ws$Reach), "Reach, River Mile ", ws$River_Sta, "\n", "Gage", ws$Gage, sep = " "), x = unit(0, "lines"), y = unit(0,"lines"), hjust = 0, vjust = 0, gp = gpar(fontsize = 12))
hg_plot <- grid.arrange(ws_plot, q_plot, nrow = 2, ncol = 1, widths = unit(7, "in"), heights = unit(c(5, 5), "in"), top = title, clip = FALSE) return(hg_plot) }