44# ' with [value_to_classes()]
55# ' @param LegendTitle String with title of the legend
66# ' @param LegendLocation Either "top" or "right" (outside the plot margin)
7+ # ' @param ... Additional legend layout arguments
78# '
89# ' @importFrom graphics legend
910# ' @export
1011# '
1112add_river_legend <- function (
12- ext_rivers , LegendTitle = " " , LegendLocation = " right"
13+ ext_rivers , LegendTitle = " " , LegendLocation = " right" , ...
1314 ){
1415
1516 if (LegendLocation == " top" ){
@@ -41,7 +42,7 @@ add_river_legend <- function(
4142
4243 nc <- length(cs )
4344 if (grepl(pattern = " ^\\ (" , x = cs [1 ])){
44- cs [1 ] <- paste0(" < " , strsplit(x = cs [1 ], split = " ," )[[1 ]][- 1 ])
45+ cs [1 ] <- paste0(" > " , strsplit(x = cs [1 ], split = " ," )[[1 ]][- 1 ])
4546 }
4647
4748 if (grepl(pattern = " \\ )$" , x = cs [nc ])){
@@ -51,21 +52,12 @@ add_river_legend <- function(
5152 cs <- gsub(pattern = " \\ (" , replacement = " > " , x = cs )
5253 cs <- gsub(pattern = " \\ ," , replacement = " - " , x = cs )
5354 cs <- gsub(pattern = " \\ ]" , replacement = " " , x = cs )
55+ cs <- gsub(pattern = " ^< -Inf - " , replacement = " " , x = cs )
56+ cs <- gsub(pattern = " - Inf$" , replacement = " " , x = cs )
5457 l_content <- cs
5558 legend(x = lx , y = ly , legend = cs , col = cc , lwd = 6 ,
5659 bg = " white" , bty = " n" , title = LegendTitle ,
57- xpd = T , xjust = xadj , yjust = 0 , horiz = hor )
60+ xpd = T , xjust = xadj , yjust = 0 , horiz = hor , ... )
5861
5962 }
60- ext_rivers $ BVK $ data $ value_class
61-
62- # ll <- length(classBreaks)
63- # l_content <-
64- # if(dataType == "time"){
65- # c(paste0("<= ", classBreaks[2]), paste0("> ", classBreaks[2:(ll-1)]))
66- # } else {
67- # c(paste0("<= ", classBreaks[2:(ll-1)]), paste0(">", classBreaks[(ll-1)]))
68- # }
69-
70-
7163}
0 commit comments