@@ -543,6 +543,7 @@ step1_figure = function(wt_event, cluster_maxima=FALSE) {
543
543
library(dplyr )
544
544
library(ggplot2 )
545
545
library(relayer ) # # git hash 8a1d49e1707d9fcc1aaa83476a3d9a15448a1065
546
+ library(ggplotify )
546
547
547
548
obs_power = get_data_plot_power(wt_event $ obs $ wt , wt_event $ input_data )
548
549
obs_t_avg_power = get_data_plot_time_avg_power(wt_event $ obs $ wt )
@@ -642,15 +643,15 @@ step1_figure = function(wt_event, cluster_maxima=FALSE) {
642
643
643
644
# # Merge the new and old data.
644
645
pd = rbind(plot_data , wt_copy )
645
-
646
+
646
647
# # Get the standard plot
647
648
gg = plot_wavelet_events(pd , do_plot = FALSE )
648
-
649
+
649
650
# # Extend the standard plot.
650
651
651
652
# # Use annotations for units labels on the y-axes.
652
653
plot_data = as.data.table(plot_data )
653
-
654
+
654
655
y_labs =
655
656
plot_data [,
656
657
.(y_center = min(y , na.rm = TRUE )+ .5 * (max(y , na.rm = TRUE )- min(y , na.rm = TRUE )),
@@ -716,11 +717,6 @@ step1_figure = function(wt_event, cluster_maxima=FALSE) {
716
717
max_stats $ y_var = ordered(' d Period' , levels = new_y_levels )
717
718
max_stats $ x = min(plot_data $ x , na.rm = TRUE ) + 3600 * (max_stats $ time )
718
719
719
- print(max_stats $ x )
720
- print(min(plot_data $ x , na.rm = TRUE ))
721
- print((max_stats $ time ))
722
- print(3600 * (max_stats $ time ))
723
-
724
720
period_y_cols = c(' y' , ' period' )
725
721
period_y_map = unique(plot_data [ y_var == ' d Period' , ..period_y_cols ])
726
722
max_stats = merge(max_stats , period_y_map , by = ' period' )
@@ -812,7 +808,7 @@ step1_figure = function(wt_event, cluster_maxima=FALSE) {
812
808
813
809
text_color = ' grey30'
814
810
text_size = 11
815
-
811
+
816
812
text_grob_1 = grid.text(
817
813
' Streamflow (cms)' , x = - 1.25 , y = .6 , hjust = .50 , vjust = - 3.5 , rot = - 90 ,
818
814
gp = gpar(col = text_color , fontsize = text_size ))
@@ -843,7 +839,7 @@ step1_figure = function(wt_event, cluster_maxima=FALSE) {
843
839
t = unique(grob $ layout [grepl(" panel-1-4" ,grob $ layout $ name ), " t" ])
844
840
g = gtable :: gtable_add_grob(g , grobs = text_grob_3 , t = t , l = ncol(g ), clip = ' off' )
845
841
846
- return (g )
842
+ return (as.ggplot( g ) )
847
843
}
848
844
849
845
@@ -857,7 +853,8 @@ step2_figure = function(
857
853
library(dplyr )
858
854
library(ggplot2 )
859
855
library(relayer ) # # git hash 8a1d49e1707d9fcc1aaa83476a3d9a15448a1065
860
-
856
+ library(ggplotify )
857
+
861
858
# # Currently this is only configured to handle a single modeled timeseries.
862
859
model_name = setdiff(names(wt_event ), c(" input_data" , " obs" ))
863
860
if (length(model_name ) > 1 )
@@ -1085,11 +1082,6 @@ step2_figure = function(
1085
1082
max_stats $ y_var = ordered(' TimePer' , levels = new_y_levels )
1086
1083
max_stats $ x = min(plot_data $ x , na.rm = TRUE ) + 3600 * (max_stats $ time )
1087
1084
1088
- print(max_stats $ x )
1089
- print(min(plot_data $ x , na.rm = TRUE ))
1090
- print((max_stats $ time ))
1091
- print(3600 * (max_stats $ time ))
1092
-
1093
1085
period_y_cols = c(' y' , ' period' )
1094
1086
period_y_map = unique(plot_data [ y_var == ' TimePer' , ..period_y_cols ])
1095
1087
max_stats = merge(max_stats , period_y_map , by = ' period' )
@@ -1228,7 +1220,7 @@ step2_figure = function(
1228
1220
guide_layout = guide_layout [c(4 ,1 ,2 ,3 ),]
1229
1221
colnames(guide_layout ) = 1 : 4
1230
1222
g $ grobs [[wh_guide_box ]]$ layout [1 : 4 ,] = guide_layout
1231
- return (g )
1223
+ return (as.ggplot( g ) )
1232
1224
}
1233
1225
1234
1226
0 commit comments