@@ -999,26 +999,12 @@ gg2list <- function(p, width = NULL, height = NULL,
999
999
}
1000
1000
traces <- c(traces , colorbar )
1001
1001
1002
- # legend title annotation - https://github.com/plotly/plotly.js/issues/276
1003
- if (isTRUE(gglayout $ showlegend )) {
1004
- legendTitles <- compact(lapply(gdefs , function (g ) if (inherits(g , " legend" )) g $ title else NULL ))
1005
- legendTitle <- paste(legendTitles , collapse = br())
1006
- titleAnnotation <- make_label(
1007
- legendTitle ,
1008
- x = gglayout $ legend $ x %|| % 1.02 ,
1009
- y = gglayout $ legend $ y %|| % 1 ,
1010
- theme $ legend.title ,
1011
- xanchor = " left" ,
1012
- yanchor = " bottom" ,
1013
- # just so the R client knows this is a title
1014
- legendTitle = TRUE
1015
- )
1016
- gglayout $ annotations <- c(gglayout $ annotations , titleAnnotation )
1017
- # adjust the height of the legend to accomodate for the title
1018
- # this assumes the legend always appears below colorbars
1019
- gglayout $ legend $ y <- (gglayout $ legend $ y %|| % 1 ) -
1020
- length(legendTitles ) * unitConvert(theme $ legend.title $ size , " npc" , " height" )
1021
- }
1002
+ legendTitles <- compact(lapply(gdefs , function (g ) if (inherits(g , " legend" )) g $ title else NULL ))
1003
+ legendTitle <- paste(legendTitles , collapse = br())
1004
+ gglayout $ legend $ title <- list (
1005
+ text = legendTitle ,
1006
+ font = text2font(theme $ legend.title )
1007
+ )
1022
1008
}
1023
1009
1024
1010
# flip x/y in traces for flipped coordinates
0 commit comments