1616# ' theme_linedraw coord_polar scale_color_distiller scale_fill_distiller
1717# ' labs expansion
1818plot_2d_specta <- function (
19- spec ,
20- time = 1L ,
21- normalize = TRUE ,
22- trim = 0.01 ,
23- cut_off = 0.4 ,
24- ... ) {
19+ spec ,
20+ time = 1L ,
21+ normalize = TRUE ,
22+ trim = 0.01 ,
23+ cut_off = 0.4 ,
24+ ...
25+ ) {
2526 if (is.character(time )) {
2627 time <- as.POSIXct(time , tz = " UTC" )
2728 }
@@ -118,10 +119,11 @@ plot_2d_specta <- function(
118119# ' theme_linedraw
119120# ' labs expansion
120121plot_1d_specta <- function (
121- spec ,
122- time = 1L ,
123- print_sea_state = TRUE ,
124- ... ) {
122+ spec ,
123+ time = 1L ,
124+ print_sea_state = TRUE ,
125+ ...
126+ ) {
125127 if (is.character(time )) {
126128 time <- as.POSIXct(time , tz = " UTC" )
127129 }
@@ -131,7 +133,9 @@ plot_1d_specta <- function(
131133 }
132134
133135 if (" freq" %nin % names(spec )) {
134- warning(" Frequency vector not provided: using the default Resourcecode frequency vector." )
136+ warning(
137+ " Frequency vector not provided: using the default Resourcecode frequency vector."
138+ )
135139 freq_plot <- rscd_freq
136140 } else {
137141 freq_plot <- spec $ freq
@@ -154,7 +158,7 @@ plot_1d_specta <- function(
154158 expand = FALSE
155159 ) +
156160 scale_y_continuous(
157- name = latex2exp :: TeX( " Wave spectral density ($m^2s) " ) ,
161+ name = " Wave spectral density (m^2.s) " ,
158162 expand = expansion(c(0 , .01 ), c(0 , .05 ))
159163 ) +
160164 labs(
@@ -163,12 +167,24 @@ plot_1d_specta <- function(
163167 caption = " Source: Resourcecode hindcast database\n resourcecode.ifremer.fr"
164168 )
165169 if (print_sea_state ) {
166- text <- paste0(" **Sea-state parameters:**\n
167- Hs=" , round(spec $ forcings $ hs [time ], 2 ), " m<br>
168- Tp=" , round(1 / spec $ forcings $ fp [time ], 2 ), " s<br>
169- Dir=" , round(spec $ forcings $ dir [time ], 2 ), " \u 00b0<br>
170- Wspd=" , round(spec $ forcings $ wnd [time ], 2 ), " m/s<br>
171- Wdir=" , round(spec $ forcings $ wnddir [time ], 2 ), " \u 00b0<br>" )
170+ text <- paste0(
171+ " **Sea-state parameters:**\n
172+ Hs=" ,
173+ round(spec $ forcings $ hs [time ], 2 ),
174+ " m<br>
175+ Tp=" ,
176+ round(1 / spec $ forcings $ fp [time ], 2 ),
177+ " s<br>
178+ Dir=" ,
179+ round(spec $ forcings $ dir [time ], 2 ),
180+ " \u 00b0<br>
181+ Wspd=" ,
182+ round(spec $ forcings $ wnd [time ], 2 ),
183+ " m/s<br>
184+ Wdir=" ,
185+ round(spec $ forcings $ wnddir [time ], 2 ),
186+ " \u 00b0<br>"
187+ )
172188
173189 out_plot <- out_plot +
174190 patchwork :: inset_element(
@@ -182,7 +198,7 @@ Wdir=", round(spec$forcings$wnddir[time], 2), "\u00b0<br>")
182198 left = 0.7 ,
183199 bottom = 0.77 ,
184200 right = .95 ,
185- top = .99
201+ top = .95
186202 )
187203 }
188204 out_plot
0 commit comments