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