@@ -1089,7 +1089,7 @@ plotListFLQuants <- function(x, probs=c(0.10, 0.33, 0.50, 0.66, 0.90),
10891089 units(i $ F ) <- paste0(fages , collapse = " -" )
10901090 return (i )
10911091 })
1092-
1092+
10931093 # GET labels
10941094 labeller <- label_flqs(x [[1 ]])
10951095
@@ -1108,25 +1108,36 @@ plotListFLQuants <- function(x, probs=c(0.10, 0.33, 0.50, 0.66, 0.90),
11081108
11091109 # ADD stock names
11101110 data <- transform(data , stock = factor (stk , levels = names(x )))
1111-
1111+
11121112 # PLOT using geom_flquantiles
11131113 p <- ggplot(data , aes(x = !! xvar , y = data , fill = stock , colour = stock )) +
11141114 facet_grid(qname ~ . , labeller = labeller , scales = " free_y" ) +
1115- # outer quantile
1116- geom_flquantiles(probs = probs [c(1 , 5 )], alpha = alpha [1 ],
1117- colour = " white" ) +
1118- # inner quantile
1119- geom_flquantiles(probs = probs [c(2 , 4 )], alpha = alpha [2 ],
1120- colour = " white" ) +
1121- # median
1122- geom_flquantiles(probs = probs [3 ], alpha = 1 ) +
11231115 xlab(" " ) + ylab(" " ) +
1124- # SET limits to include 0
1125- expand_limits(y = 0 ) +
1116+ # SET limits to include 0
1117+ expand_limits(y = 0 ) +
11261118 # SET legend with no title
11271119 theme(legend.title = element_blank()) +
11281120 # and only with lines and no title
11291121 guides(fill = " none" )
1122+
1123+ if (length(probs ) == 5 ) {
1124+ # outer quantile
1125+ p <- p + geom_flquantiles(probs = probs [c(1 , 5 )], alpha = alpha [1 ],
1126+ colour = " white" ) +
1127+ # inner quantile
1128+ geom_flquantiles(probs = probs [c(2 , 4 )], alpha = alpha [2 ],
1129+ colour = " white" ) +
1130+ # median
1131+ geom_flquantiles(probs = probs [3 ], alpha = 1 )
1132+ } else if (length(probs ) == 3 ) {
1133+ p <- p + geom_flquantiles(probs = probs [c(1 , 3 )], alpha = alpha [2 ],
1134+ colour = " white" ) +
1135+ geom_flquantiles(probs = probs [2 ], alpha = 1 )
1136+ } else if (length(probs ) == 1 ) {
1137+ p <- p + geom_flquantiles(probs = probs , alpha = 1 )
1138+ } else {
1139+ stop(" probs can only be of length 1, 3 or 5" )
1140+ }
11301141
11311142 # PLOT iter worms
11321143 if (is.numeric(worm )) {
0 commit comments