@@ -135,7 +135,8 @@ gcf_grid <- function (x = seq(0, 1, length.out = nrow(z)),
135135 ggplot2 :: theme(axis.title.y = ggplot2 :: element_blank())
136136
137137 # Cut off extra space
138- p <- p + ggplot2 :: coord_cartesian(xlim = c(min(x ), max(x )), ylim = c(min(y ), max(y )), expand = F )
138+ # p <- p + ggplot2::coord_cartesian(xlim=c(min(x), max(x)), ylim=c(min(y), max(y)), expand=F)
139+ p <- p + ggplot2 :: coord_cartesian(xlim = xlim , ylim = ylim , expand = F )
139140
140141
141142 if (mainminmax | ! is.null(main )) {
@@ -145,9 +146,17 @@ gcf_grid <- function (x = seq(0, 1, length.out = nrow(z)),
145146 ggplot2 :: theme(plot.title = ggplot2 :: element_text(hjust = 0.5 ))
146147 # Max/min annotations since colors don't work
147148 minind <- arrayInd(which.min(z ), dim(z ))
148- p <- p + ggplot2 :: annotate(" text" , x = x [minind [1 ]], y = y [minind [1 ]], label = signif(min(z ),4 ))
149+ xminz <- x [minind [1 ]]
150+ yminz <- y [minind [2 ]]
151+ xminz <- min(max(xminz , xlim [1 ]+ .025 * (xlim [2 ]- xlim [1 ])), xlim [2 ]- .025 * (xlim [2 ]- xlim [1 ]))
152+ yminz <- min(max(yminz , ylim [1 ]+ .015 * (ylim [2 ]- ylim [1 ])), ylim [2 ]- .015 * (ylim [2 ]- ylim [1 ]))
153+ p <- p + ggplot2 :: annotate(" text" , x = xminz , y = yminz , label = signif(min(z ),3 ))
149154 maxind <- arrayInd(which.max(z ), dim(z ))
150- p <- p + ggplot2 :: annotate(" text" , x = x [maxind [2 ]], y = y [maxind [2 ]], label = signif(max(z ),4 ))
155+ xmaxz <- x [maxind [1 ]]
156+ ymaxz <- y [maxind [2 ]]
157+ xmaxz <- min(max(xmaxz , xlim [1 ]+ .025 * (xlim [2 ]- xlim [1 ])), xlim [2 ]- .025 * (xlim [2 ]- xlim [1 ]))
158+ ymaxz <- min(max(ymaxz , ylim [1 ]+ .015 * (ylim [2 ]- ylim [1 ])), ylim [2 ]- .015 * (ylim [2 ]- ylim [1 ]))
159+ p <- p + ggplot2 :: annotate(" text" , x = xmaxz , y = ymaxz , label = signif(max(z ),3 ))
151160 }
152161
153162 if (! is.null(pts )) {
0 commit comments