@@ -788,10 +788,13 @@ bb2merc = function(x, cls = "ggmap") { # return bbox in the appropriate "web mer
788788# ' @param axes ignore
789789# ' @param logz ignore
790790# ' @param ... ignore
791+ # ' @param lab ignore
791792.image_scale = function (z , col , breaks = NULL , key.pos , add.axis = TRUE ,
792- at = NULL , ... , axes = FALSE , key.length , logz = FALSE ) {
793+ at = NULL , ... , axes = FALSE , key.length , logz = FALSE , lab = " " ) {
793794 if (! is.null(breaks ) && length(breaks ) != (length(col ) + 1 ))
794795 stop(" must have one more break than colour" )
796+ stopifnot(is.character(lab ) || is.expression(lab ))
797+ lab_set = (is.character(lab ) && lab != " " ) || is.expression(lab )
795798 zlim = range(z , na.rm = TRUE )
796799 if (is.null(breaks ))
797800 breaks = seq(zlim [1 ], zlim [2 ], length.out = length(col ) + 1 )
@@ -819,14 +822,16 @@ bb2merc = function(x, cls = "ggmap") { # return bbox in the appropriate "web mer
819822 xlim = c(0 , 1 )
820823 mar = c(ifelse(axes , 2.1 , 1 ), 0 , 1.2 , 0 )
821824 }
822- mar [key.pos ] = 2.1
825+ mar [key.pos ] = 2.1 + 1.5 * lab_set
823826 par(mar = mar )
824827
828+ plot(1 , 1 , t = " n" , ylim = ylim , xlim = xlim , axes = FALSE ,
829+ xlab = " " , ylab = " " , xaxs = " i" , yaxs = " i" )
830+ if (lab != " " )
831+ mtext(lab , side = key.pos , line = 2.5 , cex = .8 )
825832 poly = vector(mode = " list" , length(col ))
826833 for (i in seq(poly ))
827834 poly [[i ]] = c(breaks [i ], breaks [i + 1 ], breaks [i + 1 ], breaks [i ])
828- plot(1 , 1 , t = " n" , ylim = ylim , xlim = xlim , axes = FALSE ,
829- xlab = " " , ylab = " " , xaxs = " i" , yaxs = " i" )
830835 offset = 0.2
831836 offs = switch (key.pos ,
832837 c(0 ,0 ,- offset ,- offset ),
0 commit comments