From 4e65f3f6fc11c949481dbaaeff183983efd71676 Mon Sep 17 00:00:00 2001 From: NICOLA CORTESI Date: Tue, 21 Mar 2017 19:55:56 +0100 Subject: [PATCH 1/2] Enhancement in PlotEquiMap to adjust label distance to axes. --- R/PlotEquiMap.R | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/R/PlotEquiMap.R b/R/PlotEquiMap.R index b8b7bd60..5ab05172 100644 --- a/R/PlotEquiMap.R +++ b/R/PlotEquiMap.R @@ -12,7 +12,8 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, arr_subsamp = floor(length(lon) / 30), arr_scale = 1, arr_ref_len = 15, arr_units = "m/s", arr_scale_shaft = 1, arr_scale_shaft_angle = 1, - axelab = TRUE, labW = FALSE, + axelab = TRUE, labW = FALSE, + lab_dist_x = NULL, lab_dist_y= NULL, intylat = 20, intxlon = 20, axes_tick_scale = 1, axes_label_scale = 1, drawleg = TRUE, subsampleg = NULL, @@ -476,11 +477,14 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, mgp = c(0, spaceticklab, 0), las = 0) plot.window(xlim = range(lonb$x, finite = TRUE), ylim = range(latb$x, finite = TRUE), xaxs = 'i', yaxs = 'i') - if (axelab) { + if (axelab) { + lab_distance_y <- ifelse(is.null(lab_dist_y), spaceticklab + 0.2, lab_dist_y) + lab_distance_x <- ifelse(is.null(lab_dist_x), spaceticklab + cex_axes_labels / 2 - 0.3, lab_dist_x) axis(2, at = ypos, labels = ylabs, cex.axis = cex_axes_labels, tcl = cex_axes_ticks, - mgp = c(0, spaceticklab + 0.2, 0)) + mgp = c(0, lab_distance_y, 0)) axis(1, at = xpos, labels = xlabs, cex.axis = cex_axes_labels, tcl = cex_axes_ticks, - mgp = c(0, spaceticklab + cex_axes_labels / 2 - 0.3, 0)) + mgp = c(0, lab_distance_x, 0)) + } title(toptitle, cex.main = cex_title) rect(par("usr")[1], par("usr")[3], par("usr")[2], par("usr")[4], col = colNA) -- GitLab From fcbaf1d9be5f3d74bab68b3bcc1bb25006427d49 Mon Sep 17 00:00:00 2001 From: NICOLA CORTESI Date: Tue, 21 Mar 2017 20:06:16 +0100 Subject: [PATCH 2/2] Documentation of new options lab_dist_x and lab_dist_y --- man/PlotEquiMap.Rd | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/man/PlotEquiMap.Rd b/man/PlotEquiMap.Rd index 85d92746..b7d95961 100644 --- a/man/PlotEquiMap.Rd +++ b/man/PlotEquiMap.Rd @@ -22,6 +22,7 @@ PlotEquiMap(var, lon, lat, varu = NULL, varv = NULL, arr_ref_len = 15, arr_units = "m/s", arr_scale_shaft = 1, arr_scale_shaft_angle = 1, axelab = TRUE, labW = FALSE, + lab_dist_x = NULL, lab_dist_y = NULL, intylat = 20, intxlon = 20, axes_tick_scale = 1, axes_label_scale = 1, drawleg = TRUE, subsampleg = NULL, @@ -135,6 +136,12 @@ Whether to draw longitude and latitude axes or not. TRUE by default. \item{labW}{ Whether to label the longitude axis with a 'W' instead of minus for negative values. Defaults to FALSE. } + item{lab_dist_x}{ +Increase/decrease the distance between the box and the longitude labels. Defaults to NULL (optimal distance). +} + item{lab_dist_y}{ +Increase/decrease the distance between the box and the latitude labels. Defaults to NULL (optimal distance). +} \item{intylat}{ Interval between latitude ticks on y-axis, in degrees. Defaults to 20. } -- GitLab