From 90865a3bcd25f6ad4597b03eafd73c383bb7c981 Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Wed, 28 Sep 2016 16:03:40 +0200 Subject: [PATCH 01/11] Updated plot functions to accept width and height. --- R/Plot2VarsVsLTime.R | 13 ++++++++++--- R/PlotACC.R | 11 +++++++++-- R/PlotAno.R | 14 +++++++++++--- R/PlotBoxWhisker.R | 11 +++++++++-- R/PlotClim.R | 13 ++++++++++--- R/PlotEquiMap.R | 10 ++++++++-- R/PlotLayout.R | 10 ++++++---- R/PlotSection.R | 11 +++++++++-- R/PlotStereoMap.R | 10 ++++++++-- R/PlotVsLTime.R | 15 ++++++++++++--- R/Utils.R | 24 ++++++++---------------- man/Plot2VarsVsLTime.Rd | 21 +++++++++++++++++---- man/PlotACC.Rd | 15 ++++++++++++++- man/PlotAno.Rd | 18 +++++++++++++++--- man/PlotBoxWhisker.Rd | 13 +++++++++++++ man/PlotClim.Rd | 23 ++++++++++++++++++----- man/PlotEquiMap.Rd | 15 ++++++++++++++- man/PlotLayout.Rd | 8 +++++++- man/PlotSection.Rd | 16 +++++++++++++++- man/PlotStereoMap.Rd | 15 ++++++++++++++- man/PlotVsLTime.Rd | 25 +++++++++++++++++++------ 21 files changed, 246 insertions(+), 65 deletions(-) diff --git a/R/Plot2VarsVsLTime.R b/R/Plot2VarsVsLTime.R index ab8ebe57..4abef7a3 100644 --- a/R/Plot2VarsVsLTime.R +++ b/R/Plot2VarsVsLTime.R @@ -2,8 +2,9 @@ Plot2VarsVsLTime <- function(var1, var2, toptitle = '', ytitle = '', monini = 1, freq = 12, nticks = NULL, limits = NULL, listexp = c('exp1', 'exp2', 'exp3'), listvars = c('var1', 'var2'), biglab = FALSE, hlines = NULL, leg = TRUE, - siglev = FALSE, sizetit = 1, fileout = - 'output_plot2varsvsltime.eps', show_conf = TRUE, ...) { + siglev = FALSE, sizetit = 1, show_conf = TRUE, + fileout = 'output_plot2varsvsltime.eps', + width = 8, height = 5, units = 'in', res = 100, ...) { # Process the user graphical parameters that may be passed in the call ## Graphical parameters to exclude excludedArgs <- c("cex", "cex.axis", "cex.lab", "cex.main", "col", "fin", "lab", "las", "lty", "lwd", "mai", "mgp", "new", "pin", "ps", "pty") @@ -97,7 +98,13 @@ Plot2VarsVsLTime <- function(var1, var2, toptitle = '', ytitle = '', monini = 1, # # Open connection to graphical device - if (!is.null(fileout)) saveToFile(fileout, width = 11, height = 8) + if (!is.null(fileout)) { + saveToFile(fileout, units = units, res = res, + width = width, height = height) + } else if (names(dev.curr()) == 'null device') { + dev.new(units = units, res = res, width = width, height = height) + } + # Load the user parameters par(userArgs) diff --git a/R/PlotACC.R b/R/PlotACC.R index 6312b876..83ab2da7 100644 --- a/R/PlotACC.R +++ b/R/PlotACC.R @@ -1,7 +1,8 @@ PlotACC <- function(ACC, sdates, toptitle = "", sizetit = 1, ytitle = "", limits = NULL, legends = NULL, freq = 12, biglab = FALSE, fill = FALSE, linezero = FALSE, points = TRUE, vlines = NULL, - fileout = "output_PlotACC.eps", ...) { + fileout = "output_PlotACC.eps", + width = 8, height = 5, units = 'in', res = 100, ...) { # Process the user graphical parameters that may be passed in the call ## Graphical parameters to exclude excludedArgs <- c("cex", "cex.axis", "cex.lab", "cex.main", "col", "lab", "las", "lty", "lwd", "mai", "mgp", "new", "pch", "pin", "ps", "pty") @@ -51,7 +52,13 @@ PlotACC <- function(ACC, sdates, toptitle = "", sizetit = 1, ytitle = "", "mediumorchid1", "olivedrab1") # Open connection to graphical device - if (!is.null(fileout)) saveToFile(fileout, width = 11, height = 8) + if (!is.null(fileout)) { + saveToFile(fileout, units = units, res = res, + width = width, height = height) + } else if (names(dev.curr()) == 'null device') { + dev.new(units = units, res = res, width = width, height = height) + } + # Load the user parameters par(userArgs) diff --git a/R/PlotAno.R b/R/PlotAno.R index 495ad670..c955769c 100644 --- a/R/PlotAno.R +++ b/R/PlotAno.R @@ -5,11 +5,12 @@ PlotAno <- function(exp_ano, obs_ano = NULL, sdates, '', '', ''), limits = NULL, legends = NULL, freq = 12, biglab = FALSE, fill = TRUE, memb = TRUE, ensmean = TRUE, linezero = FALSE, - points = FALSE, vlines = NULL, + points = FALSE, vlines = NULL, sizetit = 1, fileout = c('output1_plotano.eps', 'output2_plotano.eps', 'output3_plotano.eps', 'output4_plotano.eps', 'output5_plotano.eps'), - sizetit = 1, ...) { + sizetit = 1, + width = 8, height = 5, units = 'in', res = 100, ...) { # Process the user graphical parameters that may be passed in the call ## Graphical parameters to exclude excludedArgs <- c("cex", "cex.axis", "cex.lab", "cex.main", "col", "fin", "lab", "las", "lty", "lwd", "mai", "mgp", "new", "pch", "pin", "ps", "pty") @@ -102,7 +103,14 @@ PlotAno <- function(exp_ano, obs_ano = NULL, sdates, # # Open connection to graphical device - if (!is.null(fileout)) saveToFile(fileout[jexp], width = 11, height = 8) + if (!is.null(fileout)) { + saveToFile(fileout[jexp], units = units, res = res, + width = width, height = height) + } else if (names(dev.curr()) == 'null device') { + dev.new(units = units, res = res, width = width, height = height) + } + + # Load the user parameters par(userArgs) diff --git a/R/PlotBoxWhisker.R b/R/PlotBoxWhisker.R index 1dec73fa..5db63c11 100644 --- a/R/PlotBoxWhisker.R +++ b/R/PlotBoxWhisker.R @@ -1,7 +1,8 @@ PlotBoxWhisker <- function(exp, obs, toptitle = '', ytitle = '', monini = 1, yearini = 0, freq = 1, expname = "exp 1", obsname = "obs 1", drawleg = TRUE, - fileout = "output_PlotBoxWhisker.ps", ...) { + fileout = "output_PlotBoxWhisker.ps", + width = 8, height = 5, units = 'in', res = 100, ...) { # Process the user graphical parameters that may be passed in the call ## Graphical parameters to exclude @@ -91,7 +92,13 @@ PlotBoxWhisker <- function(exp, obs, toptitle = '', ytitle = '', monini = 1, } # Open connection to graphical device - if (!is.null(fileout)) saveToFile(fileout, width = 11, height = 8) + if (!is.null(fileout)) { + saveToFile(fileout, units = units, res = res, + width = width, height = height) + } else if (names(dev.curr()) == 'null device') { + dev.new(units = units, res = res, width = width, height = height) + } + # Load the user parameters par(userArgs) diff --git a/R/PlotClim.R b/R/PlotClim.R index 80b45ddb..6ecc19ca 100644 --- a/R/PlotClim.R +++ b/R/PlotClim.R @@ -1,8 +1,9 @@ PlotClim <- function(exp_clim, obs_clim = NULL, toptitle = '', ytitle = '', monini = 1, freq = 12, limits = NULL, listexp = c('exp1', 'exp2', 'exp3'), - listobs = c('obs1', 'obs2', 'obs3'), biglab = FALSE, leg = TRUE, - fileout = 'output_plotclim.eps', sizetit = 1, ...) { + listobs = c('obs1', 'obs2', 'obs3'), biglab = FALSE, + leg = TRUE, sizetit = 1, fileout = 'output_plotclim.eps', + width = 8, height = 5, units = 'in', res = 100, ...) { # Process the user graphical parameters that may be passed in the call ## Graphical parameters to exclude excludedArgs <- c("cex", "cex.axis", "cex.lab", "cex.main", "col", "fin", "lab", "las", "lty", "lwd", "mai", "mgp", "new", "pin", "ps", "pty", "tcl") @@ -89,7 +90,13 @@ PlotClim <- function(exp_clim, obs_clim = NULL, toptitle = '', ytitle = '', # # Open connection to graphical device - if (!is.null(fileout)) saveToFile(fileout, width = 11, height = 8) + if (!is.null(fileout)) { + saveToFile(fileout, units = units, res = res, + width = width, height = height) + } else if (names(dev.curr()) == 'null device') { + dev.new(units = units, res = res, width = width, height = height) + } + # Load the user parameters par(userArgs) diff --git a/R/PlotEquiMap.R b/R/PlotEquiMap.R index bfe35716..914e3198 100644 --- a/R/PlotEquiMap.R +++ b/R/PlotEquiMap.R @@ -23,7 +23,8 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, bar_extra_margin = rep(0, 4), boxlim = NULL, boxcol = 'purple2', boxlwd = 5, margin_scale = rep(1, 4), title_scale = 1, - numbfig = NULL, fileout = NULL, ...) { + numbfig = NULL, fileout = NULL, + width = 8, height = 5, units = 'in', res = 100, ...) { # Process the user graphical parameters that may be passed in the call ## Graphical parameters to exclude excludedArgs <- c("cex", "cex.axis", "cex.lab", "cex.main", "col", "din", "fig", "fin", "lab", "las", "lty", "lwd", "mai", "mar", "mgp", "new", "oma", "ps", "tck") @@ -402,7 +403,12 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, # # Open connection to graphical device - if (!is.null(fileout)) saveToFile(fileout, width = 11, height = 8) + if (!is.null(fileout)) { + saveToFile(fileout, units = units, res = res, + width = width, height = height) + } else if (names(dev.curr()) == 'null device') { + dev.new(units = units, res = res, width = width, height = height) + } # # Defining the layout diff --git a/R/PlotLayout.R b/R/PlotLayout.R index 1b04b4cd..9e4be12c 100644 --- a/R/PlotLayout.R +++ b/R/PlotLayout.R @@ -15,7 +15,7 @@ PlotLayout <- function(fun, plot_dims, var, ..., special_args = NULL, bar_left_shift_scale = 1, bar_label_digits = 4, extra_margin = rep(0, 4), fileout = NULL, width = NULL, height = NULL, - close_device = TRUE) { + units = 'in', res = 100, close_device = TRUE) { # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { @@ -280,12 +280,14 @@ PlotLayout <- function(fun, plot_dims, var, ..., special_args = NULL, # Open connection to graphical device if (!is.null(fileout)) { - saveToFile(fileout, width = width, height = height) + saveToFile(fileout, units = units, res = res, + width = width, height = height) } else if (names(dev.cur()) == 'null device') { - dev.new(width = width, height = height) + dev.new(units = units, res = res, width = width, height = height) } else if (prod(par('mfrow')) > 1) { - dev.new(width = width, height = height) + dev.new(units = units, res = res, width = width, height = height) } + # Take size of device and set up layout: # --------------------------------------------- # |0000000000000000000000000000000000000000000| diff --git a/R/PlotSection.R b/R/PlotSection.R index c8f4df74..b95ca423 100644 --- a/R/PlotSection.R +++ b/R/PlotSection.R @@ -1,7 +1,8 @@ PlotSection <- function(var, horiz, depth, toptitle = '', sizetit = 1, units = '', brks = NULL, cols = NULL, axelab = TRUE, intydep = 200, intxhoriz = 20, drawleg = TRUE, - fileout = NULL, ...) { + fileout = NULL, width = 8, height = 5, units = 'in', + res = 100, ...) { # Process the user graphical parameters that may be passed in the call ## Graphical parameters to exclude excludedArgs <- c("cex", "cex.axis", "cex.main", "col", "lab", "las", "mai", "mar", "mgp", "new", "ps", "tck") @@ -67,7 +68,13 @@ PlotSection <- function(var, horiz, depth, toptitle = '', sizetit = 1, # # Open connection to graphical device - if (!is.null(fileout)) saveToFile(fileout, width = 11, height = 8) + if (!is.null(fileout)) { + saveToFile(fileout, units = units, res = res, + width = width, height = height) + } else if (names(dev.curr()) == 'null device') { + dev.new(units = units, res = res, width = width, height = height) + } + # Load the user parameters par(userArgs) diff --git a/R/PlotStereoMap.R b/R/PlotStereoMap.R index 74d8707e..2a019c62 100644 --- a/R/PlotStereoMap.R +++ b/R/PlotStereoMap.R @@ -15,7 +15,8 @@ PlotStereoMap <- function(var, lon, lat, latlims = c(60, 90), bar_extra_margin = rep(0, 4), boxlim = NULL, boxcol = "purple2", boxlwd = 5, margin_scale = rep(1, 4), title_scale = 1, - numbfig = NULL, fileout = NULL, ...) { + numbfig = NULL, fileout = NULL, + width = 8, height = 5, units = 'in', res = 100, ...) { # Process the user graphical parameters that may be passed in the call ## Graphical parameters to exclude excludedArgs <- c("cex", "cex.main", "col", "fin", "lab", "las", "lwd", "mai", "mar", "mgp", "new", "pch", "ps") @@ -256,7 +257,12 @@ PlotStereoMap <- function(var, lon, lat, latlims = c(60, 90), # # Open connection to graphical device - if (!is.null(fileout)) saveToFile(fileout, width = 11, height = 8) + if (!is.null(fileout)) { + saveToFile(fileout, units = units, res = res, + width = width, height = height) + } else if (names(dev.curr()) == 'null device') { + dev.new(units = units, res = res, width = width, height = height) + } # # Defining the layout diff --git a/R/PlotVsLTime.R b/R/PlotVsLTime.R index bd48aa7c..bd0171c3 100644 --- a/R/PlotVsLTime.R +++ b/R/PlotVsLTime.R @@ -2,8 +2,9 @@ PlotVsLTime <- function(var, toptitle = '', ytitle = '', monini = 1, freq = 12, nticks = NULL, limits = NULL, listexp = c('exp1', 'exp2', 'exp3'), listobs = c('obs1', 'obs2', 'obs3'), biglab = FALSE, hlines = NULL, - leg = TRUE, siglev = FALSE, fileout = 'output_plotvsltime.eps', - sizetit = 1, show_conf = TRUE, ...) { + leg = TRUE, siglev = FALSE, sizetit = 1, show_conf = TRUE, + fileout = 'output_plotvsltime.eps', + width = 8, height = 5, units = 'in', res = 100, ...) { # Process the user graphical parameters that may be passed in the call ## Graphical parameters to exclude excludedArgs <- c("cex", "cex.axis", "cex.lab", "cex.main", "col", "fin", "lab", "las", "lend", "lty", "lwd", "mai", "mgp", "new", "pin", "ps", "pty") @@ -23,6 +24,8 @@ PlotVsLTime <- function(var, toptitle = '', ytitle = '', monini = 1, freq = 12, # if (length(dim(var)) == 3) { var <- InsertDim(var, posdim = 2, lendim = 1) + } else if (length(dim(var)) != 4) { + stop("Parameter 'var' should have 3 or 4 dimensions: c(n. exp[, n. obs], 3/4, n. lead-times)") } nleadtime <- dim(var)[4] nexp <- dim(var)[1] @@ -86,7 +89,13 @@ PlotVsLTime <- function(var, toptitle = '', ytitle = '', monini = 1, freq = 12, # # Open connection to graphical device - if (!is.null(fileout)) saveToFile(fileout, width = 11, height = 8) + if (!is.null(fileout)) { + saveToFile(fileout, units = units, res = res, + width = width, height = height) + } else if (names(dev.curr()) == 'null device') { + dev.new(units = units, res = res, width = width, height = height) + } + # Load the user parameters par(userArgs) diff --git a/R/Utils.R b/R/Utils.R index 9c73fa5f..c2dd015b 100644 --- a/R/Utils.R +++ b/R/Utils.R @@ -1131,29 +1131,21 @@ # If there is an extension specified, select the correct device ## units of width and height set to accept inches if (ext[1] == ".png") { - saveToFile <- function(...) { - png(units = "in", res = 100, ...) - } + saveToFile png } else if (ext[1] == ".jpeg") { - saveToFile <- function(...) { - jpeg(units = "in", res = 100, ...) - } + saveToFile <- jpeg } else if (ext[1] == ".eps") { - saveToFile <- postscript + saveToFile <- postscript } else if (ext[1] == ".ps") { - saveToFile <- postscript + saveToFile <- postscript } else if (ext[1] == ".pdf") { - saveToFile <- pdf + saveToFile <- pdf } else if (ext[1] == ".svg") { - saveToFile <- svg + saveToFile <- svg } else if (ext[1] == ".bmp") { - saveToFile <- function(...) { - bmp(units = "in", res = 100, ...) - } + saveToFile <- bmp } else if (ext[1] == ".tiff") { - saveToFile <- function(...) { - tiff(units = "in", res = 100, ...) - } + saveToFile <- tiff } else { .warning("file extension not supported, it will be used '.eps' by default.") ## In case there is only one filename diff --git a/man/Plot2VarsVsLTime.Rd b/man/Plot2VarsVsLTime.Rd index 91b57c62..68a85f9c 100644 --- a/man/Plot2VarsVsLTime.Rd +++ b/man/Plot2VarsVsLTime.Rd @@ -13,8 +13,9 @@ Plot2VarsVsLTime(var1, var2, toptitle = "", ytitle = "", monini = 1, freq = 12, nticks = NULL, limits = NULL, listexp = c("exp1", "exp2", "exp3"), listvars = c("var1", "var2"), biglab = FALSE, hlines = NULL, - leg = TRUE, siglev = FALSE, sizetit = 1, - fileout = "output_plot2varsvsltime.eps", show_conf = TRUE, ...) + leg = TRUE, siglev = FALSE, sizetit = 1, show_conf = TRUE, + fileout = "output_plot2varsvsltime.eps", + width = 8, height = 5, units = 'in', res = 100, ...) } \arguments{ \item{var1}{ @@ -63,14 +64,26 @@ Default = FALSE. } \item{sizetit}{ Multiplicative factor to change title size, optional. + } + \item{show_conf}{ +TRUE/FALSE to show/not confidence intervals for input variables. } \item{fileout}{ Name of output file. Extensions allowed: eps/ps, jpeg, png, pdf, bmp and tiff. \cr Default = 'output_plot2varsvsltime.eps' } - \item{show_conf}{ -TRUE/FALSE to show/not confidence intervals for input variables. + \item{width}{ +File width, in the units specified in the parameter units (inches by default). Takes 8 by default. + } + \item{height}{ +File height, in the units specified in the parameter units (inches by default). Takes 5 by default. + } + \item{units}{ +Units of the size of the device (file or window) to plot in. Inches ('in') by default. See ?Devices and the creator function of the corresponding device. + } + \item{res}{ +Resolution of the device (file or window) to plot in. See ?Devices and the creator function of the corresponding device. } \item{...}{ Arguments to be passed to the method. Only accepts the following diff --git a/man/PlotACC.Rd b/man/PlotACC.Rd index 9489413a..fcd8a662 100644 --- a/man/PlotACC.Rd +++ b/man/PlotACC.Rd @@ -12,7 +12,8 @@ with the fourth dimension of length 4 containing the lower limit of the 95\% con PlotACC(ACC, sdates, toptitle = "", sizetit = 1, ytitle = "", limits = NULL, legends = NULL, freq = 12, biglab = FALSE, fill = FALSE, linezero = FALSE, points = TRUE, vlines = NULL, - fileout = "output_PlotACC.eps", ...) + fileout = "output_PlotACC.eps", + width = 8, height = 5, units = 'in', res = 100, ...) } \arguments{ \item{ACC}{ @@ -61,6 +62,18 @@ List of x location where to add vertical black lines, optional. Name of output file. Extensions allowed: eps/ps, jpeg, png, pdf, bmp and tiff. \cr Default = 'output_PlotACC.eps' + } + \item{width}{ +File width, in the units specified in the parameter units (inches by default). Takes 8 by default. + } + \item{height}{ +File height, in the units specified in the parameter units (inches by default). Takes 5 by default. + } + \item{units}{ +Units of the size of the device (file or window) to plot in. Inches ('in') by default. See ?Devices and the creator function of the corresponding device. + } + \item{res}{ +Resolution of the device (file or window) to plot in. See ?Devices and the creator function of the corresponding device. } \item{...}{ Arguments to be passed to the method. Only accepts the following diff --git a/man/PlotAno.Rd b/man/PlotAno.Rd index 5699e362..6a8cbf25 100644 --- a/man/PlotAno.Rd +++ b/man/PlotAno.Rd @@ -16,7 +16,7 @@ PlotAno(exp_ano, obs_ano = NULL, sdates, toptitle = c("", "", "", "", "", "", ensmean = TRUE, linezero = FALSE, points = FALSE, vlines = NULL, fileout = c("output1_plotano.eps", "output2_plotano.eps", "output3_plotano.eps", "output4_plotano.eps", "output5_plotano.eps"), - sizetit = 1, ...) + sizetit = 1, width = 8, height = 5, units = 'in', res = 100, ...) } \arguments{ \item{exp_ano}{ @@ -66,6 +66,9 @@ TRUE/FALSE if points instead of lines should be shown. Default = FALSE. } \item{vlines}{ List of x location where to add vertical black lines, optional. + } + \item{sizetit}{ +Multiplicative factor to scale title size, optional. } \item{fileout}{ Name of the output file for each experiment: c('',''). @@ -76,8 +79,17 @@ Default = c('output1_plotano.eps', 'output2_plotano.eps', 'output3_plotano.eps', 'output4_plotano.eps', 'output5_plotano.eps') } - \item{sizetit}{ -Multiplicative factor to scale title size, optional. + \item{width}{ +File width, in the units specified in the parameter units (inches by default). Takes 8 by default. + } + \item{height}{ +File height, in the units specified in the parameter units (inches by default). Takes 5 by default. + } + \item{units}{ +Units of the size of the device (file or window) to plot in. Inches ('in') by default. See ?Devices and the creator function of the corresponding device. + } + \item{res}{ +Resolution of the device (file or window) to plot in. See ?Devices and the creator function of the corresponding device. } \item{...}{ Arguments to be passed to the method. Only accepts the following diff --git a/man/PlotBoxWhisker.Rd b/man/PlotBoxWhisker.Rd index 30422101..4129aa59 100644 --- a/man/PlotBoxWhisker.Rd +++ b/man/PlotBoxWhisker.Rd @@ -12,6 +12,7 @@ n-monthly to n-yearly time series. \usage{ PlotBoxWhisker(exp, obs, toptitle = '', ytitle = '', monini = 1, yearini = 0, freq = 1, expname = "exp 1", obsname = "obs 1", drawleg = TRUE, + width = 8, height = 5, units = 'in', res = 100, fileout = "output_PlotBoxWhisker.ps", ...) } \arguments{ @@ -58,6 +59,18 @@ TRUE/FALSE: whether to draw the legend or not. Name of output file. Extensions allowed: eps/ps, jpeg, png, pdf, bmp and tiff. \cr Default = 'output_PlotBox.ps' + } + \item{width}{ +File width, in the units specified in the parameter units (inches by default). Takes 8 by default. + } + \item{height}{ +File height, in the units specified in the parameter units (inches by default). Takes 5 by default. + } + \item{units}{ +Units of the size of the device (file or window) to plot in. Inches ('in') by default. See ?Devices and the creator function of the corresponding device. + } + \item{res}{ +Resolution of the device (file or window) to plot in. See ?Devices and the creator function of the corresponding device. } \item{...}{ Arguments to be passed to the method. Only accepts the following diff --git a/man/PlotClim.Rd b/man/PlotClim.Rd index e95602d4..7c796ba4 100644 --- a/man/PlotClim.Rd +++ b/man/PlotClim.Rd @@ -12,7 +12,8 @@ Plots climatologies as a function of the forecast time for any index output from PlotClim(exp_clim, obs_clim = NULL, toptitle = "", ytitle = "", monini = 1, freq = 12, limits = NULL, listexp = c("exp1", "exp2", "exp3"), listobs = c("obs1", "obs2", "obs3"), biglab = FALSE, leg = TRUE, - fileout = "output_plotclim.eps", sizetit = 1, ...) + sizetit = 1, width = 8, height = 5, units = 'in', res = 100, + fileout = "output_plotclim.eps", ...) } \arguments{ \item{exp_clim}{ @@ -50,13 +51,25 @@ TRUE/FALSE for presentation/paper plot. Default = FALSE. \item{leg}{ TRUE/FALSE to plot the legend or not. } - \item{fileout}{ + \item{sizetit}{ +Multiplicative factor to scale title size, optional. + } + \item{width}{ +File width, in the units specified in the parameter units (inches by default). Takes 8 by default. + } + \item{height}{ +File height, in the units specified in the parameter units (inches by default). Takes 5 by default. + } + \item{units}{ +Units of the size of the device (file or window) to plot in. Inches ('in') by default. See ?Devices and the creator function of the corresponding device. + } + \item{res}{ +Resolution of the device (file or window) to plot in. See ?Devices and the creator function of the corresponding device. + } + \item{fileout}{ Name of output file. Extensions allowed: eps/ps, jpeg, png, pdf, bmp and tiff. \cr Default = 'output_plotclim.eps' - } - \item{sizetit}{ -Multiplicative factor to scale title size, optional. } \item{...}{ Arguments to be passed to the method. Only accepts the following diff --git a/man/PlotEquiMap.Rd b/man/PlotEquiMap.Rd index 55eec399..ac4792ab 100644 --- a/man/PlotEquiMap.Rd +++ b/man/PlotEquiMap.Rd @@ -32,7 +32,8 @@ PlotEquiMap(var, lon, lat, varu = NULL, varv = NULL, bar_extra_margin = rep(0, 4), boxlim = NULL, boxcol = 'purple2', boxlwd = 5, margin_scale = rep(1, 4), title_scale = 1, - numbfig = NULL, fileout = NULL, ...) + numbfig = NULL, fileout = NULL, + width = 8, height = 5, units = 'in', res = 100, ...) } \arguments{ \item{var}{ @@ -169,6 +170,18 @@ Number of figures in the layout the plot will be put into. A higher numbfig will } \item{fileout}{ File where to save the plot. If not specified (default) a graphics device will pop up. Extensions allowed: eps/ps, jpeg, png, pdf, bmp and tiff. \cr + } + \item{width}{ +File width, in the units specified in the parameter units (inches by default). Takes 8 by default. + } + \item{height}{ +File height, in the units specified in the parameter units (inches by default). Takes 5 by default. + } + \item{units}{ +Units of the size of the device (file or window) to plot in. Inches ('in') by default. See ?Devices and the creator function of the corresponding device. + } + \item{res}{ +Resolution of the device (file or window) to plot in. See ?Devices and the creator function of the corresponding device. } \item{\dots}{ Arguments to be passed to the method. Only accepts the following graphical parameters: diff --git a/man/PlotLayout.Rd b/man/PlotLayout.Rd index 54e03d3d..c64a46aa 100644 --- a/man/PlotLayout.Rd +++ b/man/PlotLayout.Rd @@ -25,7 +25,7 @@ PlotLayout(fun, plot_dims, var, ..., special_args = NULL, bar_left_shift_scale = 1, bar_label_digits = 4, extra_margin = rep(0, 4), fileout = NULL, width = NULL, height = NULL, - close_device = TRUE) + units = 'in', res = 100, close_device = TRUE) } \arguments{ \item{fun}{ @@ -112,6 +112,12 @@ Width in inches of the multi-pannel. 7 by default, or 11 if 'fielout' has been s } \item{height}{ Height in inches of the multi-pannel. 7 by default, or 11 if 'fileout' has been specified. + } + \item{units}{ +Units of the size of the device (file or window) to plot in. Inches ('in') by default. See ?Devices and the creator function of the corresponding device. + } + \item{res}{ +Resolution of the device (file or window) to plot in. See ?Devices and the creator function of the corresponding device. } \item{close_device}{ Whether to close the graphics device after plotting the layout and a 'fileout' has been specified. This is useful to avoid closing the device when saving the layout into a file and willing to add extra elements or figures. Takes TRUE by default. Disregarded if no 'fileout' has been specified. diff --git a/man/PlotSection.Rd b/man/PlotSection.Rd index d02df3ec..0bb19fa9 100644 --- a/man/PlotSection.Rd +++ b/man/PlotSection.Rd @@ -9,7 +9,9 @@ Plot a (longitude,depth) or (latitude,depth) section. \usage{ PlotSection(var, horiz, depth, toptitle = "", sizetit = 1, units = "", brks = NULL, cols = NULL, axelab = TRUE, intydep = 200, - intxhoriz = 20, drawleg = TRUE, fileout = NULL, ...) + intxhoriz = 20, drawleg = TRUE, + width = 8, height = 5, units = 'in', res = 100, + fileout = NULL, ...) } \arguments{ \item{var}{ @@ -48,6 +50,18 @@ Default: 20deg. } \item{drawleg}{ Draw colorbar. Default: TRUE. + } + \item{width}{ +File width, in the units specified in the parameter units (inches by default). Takes 8 by default. + } + \item{height}{ +File height, in the units specified in the parameter units (inches by default). Takes 5 by default. + } + \item{units}{ +Units of the size of the device (file or window) to plot in. Inches ('in') by default. See ?Devices and the creator function of the corresponding device. + } + \item{res}{ +Resolution of the device (file or window) to plot in. See ?Devices and the creator function of the corresponding device. } \item{fileout}{ Name of output file. Extensions allowed: eps/ps, jpeg, png, pdf, bmp diff --git a/man/PlotStereoMap.Rd b/man/PlotStereoMap.Rd index 1f6a4f6e..22105e83 100644 --- a/man/PlotStereoMap.Rd +++ b/man/PlotStereoMap.Rd @@ -24,7 +24,8 @@ PlotStereoMap(var, lon, lat, latlims = c(60, 90), bar_extra_margin = rep(0, 4), boxlim = NULL, boxcol = "purple2", boxlwd = 5, margin_scale = rep(1, 4), title_scale = 1, - numbfig = NULL, fileout = NULL, ...) + numbfig = NULL, width = 8, height = 5, units = 'in', res = 100, + fileout = NULL, ...) } \arguments{ \item{var}{ @@ -103,6 +104,18 @@ Number of figures in the layout the plot will be put into. A higher numbfig will } \item{fileout}{ File where to save the plot. If not specified (default) a graphics device will pop up. Extensions allowed: eps/ps, jpeg, png, pdf, bmp and tiff. \cr + } + \item{width}{ +File width, in the units specified in the parameter units (inches by default). Takes 8 by default. + } + \item{height}{ +File height, in the units specified in the parameter units (inches by default). Takes 5 by default. + } + \item{units}{ +Units of the size of the device (file or window) to plot in. Inches ('in') by default. See ?Devices and the creator function of the corresponding device. + } + \item{res}{ +Resolution of the device (file or window) to plot in. See ?Devices and the creator function of the corresponding device. } \item{\dots}{ Arguments to be passed to the method. Only accepts the following graphical parameters: diff --git a/man/PlotVsLTime.Rd b/man/PlotVsLTime.Rd index 6ce6edd6..ee0417c4 100644 --- a/man/PlotVsLTime.Rd +++ b/man/PlotVsLTime.Rd @@ -10,8 +10,9 @@ Plots The Correlation (\code{Corr()}) or the Root Mean Square Error (\code{RMS() PlotVsLTime(var, toptitle = "", ytitle = "", monini = 1, freq = 12, nticks = NULL, limits = NULL, listexp = c("exp1", "exp2", "exp3"), listobs = c("obs1", "obs2", "obs3"), biglab = FALSE, hlines = NULL, - leg = TRUE, siglev = FALSE, fileout = "output_plotvsltime.eps", - sizetit = 1, show_conf = TRUE, ...) + leg = TRUE, siglev = FALSE, sizetit = 1, show_conf = TRUE, + fileout = "output_plotvsltime.eps", + width = 8, height = 5, units = 'in', res = 100, ...) } \arguments{ \item{var}{ @@ -56,17 +57,29 @@ TRUE/FALSE if legend should be added or not to the plot. Default = TRUE. \item{siglev}{ TRUE/FALSE if significance level should replace confidence interval.\cr Default = FALSE. + } + \item{sizetit}{ +Multiplicative factor to change title size, optional. + } + \item{show_conf}{ +TRUE/FALSE to show/not confidence intervals for input variables. } \item{fileout}{ Name of output file. Extensions allowed: eps/ps, jpeg, png, pdf, bmp and tiff.\cr Default = 'output_plotvsltime.eps' } - \item{sizetit}{ -Multiplicative factor to change title size, optional. + \item{width}{ +File width, in the units specified in the parameter units (inches by default). Takes 8 by default. } - \item{show_conf}{ -TRUE/FALSE to show/not confidence intervals for input variables. + \item{height}{ +File height, in the units specified in the parameter units (inches by default). Takes 5 by default. + } + \item{units}{ +Units of the size of the device (file or window) to plot in. Inches ('in') by default. See ?Devices and the creator function of the corresponding device. + } + \item{res}{ +Resolution of the device (file or window) to plot in. See ?Devices and the creator function of the corresponding device. } \item{...}{ Arguments to be passed to the method. Only accepts the following -- GitLab From ab0c9f1901ad72ebe429dc1071080d44ecf1be77 Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Wed, 28 Sep 2016 16:07:31 +0200 Subject: [PATCH 02/11] Small fix. --- R/PlotAno.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/PlotAno.R b/R/PlotAno.R index c955769c..8f9a7de5 100644 --- a/R/PlotAno.R +++ b/R/PlotAno.R @@ -9,7 +9,6 @@ PlotAno <- function(exp_ano, obs_ano = NULL, sdates, fileout = c('output1_plotano.eps', 'output2_plotano.eps', 'output3_plotano.eps', 'output4_plotano.eps', 'output5_plotano.eps'), - sizetit = 1, width = 8, height = 5, units = 'in', res = 100, ...) { # Process the user graphical parameters that may be passed in the call ## Graphical parameters to exclude -- GitLab From e348d17480df34c8fd61844a788d80c8ef5ff8b7 Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Wed, 28 Sep 2016 16:24:20 +0200 Subject: [PATCH 03/11] Small fix. --- R/Plot2VarsVsLTime.R | 6 +++--- R/PlotACC.R | 6 +++--- R/PlotAno.R | 6 +++--- R/PlotBoxWhisker.R | 6 +++--- R/PlotClim.R | 6 +++--- R/PlotEquiMap.R | 7 ++++--- R/PlotLayout.R | 24 ++++++++++++------------ R/PlotSection.R | 8 ++++---- R/PlotStereoMap.R | 7 ++++--- R/PlotVsLTime.R | 6 +++--- man/PlotACC.Rd | 8 ++++---- man/PlotAno.Rd | 8 ++++---- man/PlotBoxWhisker.Rd | 8 ++++---- man/PlotClim.Rd | 8 ++++---- man/PlotEquiMap.Rd | 8 ++++---- man/PlotLayout.Rd | 4 ++-- man/PlotSection.Rd | 8 ++++---- man/PlotStereoMap.Rd | 8 ++++---- man/PlotVsLTime.Rd | 8 ++++---- 19 files changed, 76 insertions(+), 74 deletions(-) diff --git a/R/Plot2VarsVsLTime.R b/R/Plot2VarsVsLTime.R index 4abef7a3..1a55500e 100644 --- a/R/Plot2VarsVsLTime.R +++ b/R/Plot2VarsVsLTime.R @@ -4,7 +4,7 @@ Plot2VarsVsLTime <- function(var1, var2, toptitle = '', ytitle = '', monini = 1, 'var2'), biglab = FALSE, hlines = NULL, leg = TRUE, siglev = FALSE, sizetit = 1, show_conf = TRUE, fileout = 'output_plot2varsvsltime.eps', - width = 8, height = 5, units = 'in', res = 100, ...) { + width = 8, height = 5, size_units = 'in', res = 100, ...) { # Process the user graphical parameters that may be passed in the call ## Graphical parameters to exclude excludedArgs <- c("cex", "cex.axis", "cex.lab", "cex.main", "col", "fin", "lab", "las", "lty", "lwd", "mai", "mgp", "new", "pin", "ps", "pty") @@ -99,10 +99,10 @@ Plot2VarsVsLTime <- function(var1, var2, toptitle = '', ytitle = '', monini = 1, # Open connection to graphical device if (!is.null(fileout)) { - saveToFile(fileout, units = units, res = res, + saveToFile(fileout, units = size_units, res = res, width = width, height = height) } else if (names(dev.curr()) == 'null device') { - dev.new(units = units, res = res, width = width, height = height) + dev.new(units = size_units, res = res, width = width, height = height) } # Load the user parameters diff --git a/R/PlotACC.R b/R/PlotACC.R index 83ab2da7..84104ffd 100644 --- a/R/PlotACC.R +++ b/R/PlotACC.R @@ -2,7 +2,7 @@ PlotACC <- function(ACC, sdates, toptitle = "", sizetit = 1, ytitle = "", limits = NULL, legends = NULL, freq = 12, biglab = FALSE, fill = FALSE, linezero = FALSE, points = TRUE, vlines = NULL, fileout = "output_PlotACC.eps", - width = 8, height = 5, units = 'in', res = 100, ...) { + width = 8, height = 5, size_units = 'in', res = 100, ...) { # Process the user graphical parameters that may be passed in the call ## Graphical parameters to exclude excludedArgs <- c("cex", "cex.axis", "cex.lab", "cex.main", "col", "lab", "las", "lty", "lwd", "mai", "mgp", "new", "pch", "pin", "ps", "pty") @@ -53,10 +53,10 @@ PlotACC <- function(ACC, sdates, toptitle = "", sizetit = 1, ytitle = "", # Open connection to graphical device if (!is.null(fileout)) { - saveToFile(fileout, units = units, res = res, + saveToFile(fileout, units = size_units, res = res, width = width, height = height) } else if (names(dev.curr()) == 'null device') { - dev.new(units = units, res = res, width = width, height = height) + dev.new(units = size_units, res = res, width = width, height = height) } # Load the user parameters diff --git a/R/PlotAno.R b/R/PlotAno.R index 8f9a7de5..615240d4 100644 --- a/R/PlotAno.R +++ b/R/PlotAno.R @@ -9,7 +9,7 @@ PlotAno <- function(exp_ano, obs_ano = NULL, sdates, fileout = c('output1_plotano.eps', 'output2_plotano.eps', 'output3_plotano.eps', 'output4_plotano.eps', 'output5_plotano.eps'), - width = 8, height = 5, units = 'in', res = 100, ...) { + width = 8, height = 5, size_units = 'in', res = 100, ...) { # Process the user graphical parameters that may be passed in the call ## Graphical parameters to exclude excludedArgs <- c("cex", "cex.axis", "cex.lab", "cex.main", "col", "fin", "lab", "las", "lty", "lwd", "mai", "mgp", "new", "pch", "pin", "ps", "pty") @@ -103,10 +103,10 @@ PlotAno <- function(exp_ano, obs_ano = NULL, sdates, # Open connection to graphical device if (!is.null(fileout)) { - saveToFile(fileout[jexp], units = units, res = res, + saveToFile(fileout[jexp], units = size_units, res = res, width = width, height = height) } else if (names(dev.curr()) == 'null device') { - dev.new(units = units, res = res, width = width, height = height) + dev.new(units = size_units, res = res, width = width, height = height) } diff --git a/R/PlotBoxWhisker.R b/R/PlotBoxWhisker.R index 5db63c11..5eede493 100644 --- a/R/PlotBoxWhisker.R +++ b/R/PlotBoxWhisker.R @@ -2,7 +2,7 @@ PlotBoxWhisker <- function(exp, obs, toptitle = '', ytitle = '', monini = 1, yearini = 0, freq = 1, expname = "exp 1", obsname = "obs 1", drawleg = TRUE, fileout = "output_PlotBoxWhisker.ps", - width = 8, height = 5, units = 'in', res = 100, ...) { + width = 8, height = 5, size_units = 'in', res = 100, ...) { # Process the user graphical parameters that may be passed in the call ## Graphical parameters to exclude @@ -93,10 +93,10 @@ PlotBoxWhisker <- function(exp, obs, toptitle = '', ytitle = '', monini = 1, # Open connection to graphical device if (!is.null(fileout)) { - saveToFile(fileout, units = units, res = res, + saveToFile(fileout, units = size_units, res = res, width = width, height = height) } else if (names(dev.curr()) == 'null device') { - dev.new(units = units, res = res, width = width, height = height) + dev.new(units = size_units, res = res, width = width, height = height) } # Load the user parameters diff --git a/R/PlotClim.R b/R/PlotClim.R index 6ecc19ca..f88eadd1 100644 --- a/R/PlotClim.R +++ b/R/PlotClim.R @@ -3,7 +3,7 @@ PlotClim <- function(exp_clim, obs_clim = NULL, toptitle = '', ytitle = '', listexp = c('exp1', 'exp2', 'exp3'), listobs = c('obs1', 'obs2', 'obs3'), biglab = FALSE, leg = TRUE, sizetit = 1, fileout = 'output_plotclim.eps', - width = 8, height = 5, units = 'in', res = 100, ...) { + width = 8, height = 5, size_units = 'in', res = 100, ...) { # Process the user graphical parameters that may be passed in the call ## Graphical parameters to exclude excludedArgs <- c("cex", "cex.axis", "cex.lab", "cex.main", "col", "fin", "lab", "las", "lty", "lwd", "mai", "mgp", "new", "pin", "ps", "pty", "tcl") @@ -91,10 +91,10 @@ PlotClim <- function(exp_clim, obs_clim = NULL, toptitle = '', ytitle = '', # Open connection to graphical device if (!is.null(fileout)) { - saveToFile(fileout, units = units, res = res, + saveToFile(fileout, units = size_units, res = res, width = width, height = height) } else if (names(dev.curr()) == 'null device') { - dev.new(units = units, res = res, width = width, height = height) + dev.new(units = size_units, res = res, width = width, height = height) } # Load the user parameters diff --git a/R/PlotEquiMap.R b/R/PlotEquiMap.R index 914e3198..deaf055c 100644 --- a/R/PlotEquiMap.R +++ b/R/PlotEquiMap.R @@ -24,7 +24,8 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, boxlim = NULL, boxcol = 'purple2', boxlwd = 5, margin_scale = rep(1, 4), title_scale = 1, numbfig = NULL, fileout = NULL, - width = 8, height = 5, units = 'in', res = 100, ...) { + width = 8, height = 5, size_units = 'in', + res = 100, ...) { # Process the user graphical parameters that may be passed in the call ## Graphical parameters to exclude excludedArgs <- c("cex", "cex.axis", "cex.lab", "cex.main", "col", "din", "fig", "fin", "lab", "las", "lty", "lwd", "mai", "mar", "mgp", "new", "oma", "ps", "tck") @@ -404,10 +405,10 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, # Open connection to graphical device if (!is.null(fileout)) { - saveToFile(fileout, units = units, res = res, + saveToFile(fileout, units = size_units, res = res, width = width, height = height) } else if (names(dev.curr()) == 'null device') { - dev.new(units = units, res = res, width = width, height = height) + dev.new(units = size_units, res = res, width = width, height = height) } # diff --git a/R/PlotLayout.R b/R/PlotLayout.R index 9e4be12c..d179c48a 100644 --- a/R/PlotLayout.R +++ b/R/PlotLayout.R @@ -15,7 +15,7 @@ PlotLayout <- function(fun, plot_dims, var, ..., special_args = NULL, bar_left_shift_scale = 1, bar_label_digits = 4, extra_margin = rep(0, 4), fileout = NULL, width = NULL, height = NULL, - units = 'in', res = 100, close_device = TRUE) { + size_units = 'in', res = 100, close_device = TRUE) { # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { @@ -280,10 +280,10 @@ PlotLayout <- function(fun, plot_dims, var, ..., special_args = NULL, # Open connection to graphical device if (!is.null(fileout)) { - saveToFile(fileout, units = units, res = res, + saveToFile(fileout, units = size_units, res = res, width = width, height = height) } else if (names(dev.cur()) == 'null device') { - dev.new(units = units, res = res, width = width, height = height) + dev.new(units = size_units, res = res, width = width, height = height) } else if (prod(par('mfrow')) > 1) { dev.new(units = units, res = res, width = width, height = height) } @@ -384,13 +384,13 @@ PlotLayout <- function(fun, plot_dims, var, ..., special_args = NULL, width_lines <- par('fin')[1] / par('csi') plot_lines <- par('pin')[1] / par('csi') plot_range <- par('xaxp')[2] - par('xaxp')[1] - plot_units_per_line <- plot_range / plot_lines + size_units_per_line <- plot_range / plot_lines if (toptitle != '') { - title_x_center <- par('xaxp')[1] - par('mar')[2] * plot_units_per_line + - ncol * width_lines * plot_units_per_line / 2 + title_x_center <- par('xaxp')[1] - par('mar')[2] * size_units_per_line + + ncol * width_lines * size_units_per_line / 2 if (length(row_titles) > 0) { title_x_center <- title_x_center - (1 - title_left_shift_scale) * - (subtitle_cex + subtitle_margin) / 2 * plot_units_per_line + (subtitle_cex + subtitle_margin) / 2 * size_units_per_line } title_y_center <- par('mar')[3] + (title_margin + title_cex) / 2 if (length(col_titles > 0)) { @@ -400,24 +400,24 @@ PlotLayout <- function(fun, plot_dims, var, ..., special_args = NULL, padj = 0.5) } if (length(col_titles) > 0) { - t_x_center <- par('xaxp')[1] - par('mar')[2] * plot_units_per_line + t_x_center <- par('xaxp')[1] - par('mar')[2] * size_units_per_line for (t in 1:ncol) { mtext(col_titles[t], cex = subtitle_cex, line = par('mar')[3] + (subtitle_margin + subtitle_cex) / 2, - at = t_x_center + (t - 0.5) * width_lines * plot_units_per_line, + at = t_x_center + (t - 0.5) * width_lines * size_units_per_line, padj = 0.5) } } height_lines <- par('fin')[2] / par('csi') plot_lines <- par('pin')[2] / par('csi') plot_range <- par('yaxp')[2] - par('yaxp')[1] - plot_units_per_line <- plot_range / plot_lines + size_units_per_line <- plot_range / plot_lines if (length(row_titles) > 0) { - t_y_center <- par('yaxp')[1] - par('mar')[1] * plot_units_per_line + t_y_center <- par('yaxp')[1] - par('mar')[1] * size_units_per_line for (t in 1:nrow) { mtext(row_titles[t], cex = subtitle_cex, line = par('mar')[2] + (subtitle_margin + subtitle_cex) / 2, - at = t_y_center - (t - 1.5) * height_lines * plot_units_per_line, + at = t_y_center - (t - 1.5) * height_lines * size_units_per_line, padj = 0.5, side = 2) } } diff --git a/R/PlotSection.R b/R/PlotSection.R index b95ca423..ac21ae26 100644 --- a/R/PlotSection.R +++ b/R/PlotSection.R @@ -1,8 +1,8 @@ PlotSection <- function(var, horiz, depth, toptitle = '', sizetit = 1, units = '', brks = NULL, cols = NULL, axelab = TRUE, intydep = 200, intxhoriz = 20, drawleg = TRUE, - fileout = NULL, width = 8, height = 5, units = 'in', - res = 100, ...) { + fileout = NULL, width = 8, height = 5, + size_units = 'in', res = 100, ...) { # Process the user graphical parameters that may be passed in the call ## Graphical parameters to exclude excludedArgs <- c("cex", "cex.axis", "cex.main", "col", "lab", "las", "mai", "mar", "mgp", "new", "ps", "tck") @@ -69,10 +69,10 @@ PlotSection <- function(var, horiz, depth, toptitle = '', sizetit = 1, # Open connection to graphical device if (!is.null(fileout)) { - saveToFile(fileout, units = units, res = res, + saveToFile(fileout, units = size_units, res = res, width = width, height = height) } else if (names(dev.curr()) == 'null device') { - dev.new(units = units, res = res, width = width, height = height) + dev.new(units = size_units, res = res, width = width, height = height) } # Load the user parameters diff --git a/R/PlotStereoMap.R b/R/PlotStereoMap.R index 2a019c62..6fc47536 100644 --- a/R/PlotStereoMap.R +++ b/R/PlotStereoMap.R @@ -16,7 +16,8 @@ PlotStereoMap <- function(var, lon, lat, latlims = c(60, 90), boxlim = NULL, boxcol = "purple2", boxlwd = 5, margin_scale = rep(1, 4), title_scale = 1, numbfig = NULL, fileout = NULL, - width = 8, height = 5, units = 'in', res = 100, ...) { + width = 8, height = 5, size_units = 'in', + res = 100, ...) { # Process the user graphical parameters that may be passed in the call ## Graphical parameters to exclude excludedArgs <- c("cex", "cex.main", "col", "fin", "lab", "las", "lwd", "mai", "mar", "mgp", "new", "pch", "ps") @@ -258,10 +259,10 @@ PlotStereoMap <- function(var, lon, lat, latlims = c(60, 90), # Open connection to graphical device if (!is.null(fileout)) { - saveToFile(fileout, units = units, res = res, + saveToFile(fileout, units = size_units, res = res, width = width, height = height) } else if (names(dev.curr()) == 'null device') { - dev.new(units = units, res = res, width = width, height = height) + dev.new(units = size_units, res = res, width = width, height = height) } # diff --git a/R/PlotVsLTime.R b/R/PlotVsLTime.R index bd0171c3..6b168483 100644 --- a/R/PlotVsLTime.R +++ b/R/PlotVsLTime.R @@ -4,7 +4,7 @@ PlotVsLTime <- function(var, toptitle = '', ytitle = '', monini = 1, freq = 12, listobs = c('obs1', 'obs2', 'obs3'), biglab = FALSE, hlines = NULL, leg = TRUE, siglev = FALSE, sizetit = 1, show_conf = TRUE, fileout = 'output_plotvsltime.eps', - width = 8, height = 5, units = 'in', res = 100, ...) { + width = 8, height = 5, size_units = 'in', res = 100, ...) { # Process the user graphical parameters that may be passed in the call ## Graphical parameters to exclude excludedArgs <- c("cex", "cex.axis", "cex.lab", "cex.main", "col", "fin", "lab", "las", "lend", "lty", "lwd", "mai", "mgp", "new", "pin", "ps", "pty") @@ -90,10 +90,10 @@ PlotVsLTime <- function(var, toptitle = '', ytitle = '', monini = 1, freq = 12, # Open connection to graphical device if (!is.null(fileout)) { - saveToFile(fileout, units = units, res = res, + saveToFile(fileout, units = size_units, res = res, width = width, height = height) } else if (names(dev.curr()) == 'null device') { - dev.new(units = units, res = res, width = width, height = height) + dev.new(units = size_units, res = res, width = width, height = height) } # Load the user parameters diff --git a/man/PlotACC.Rd b/man/PlotACC.Rd index fcd8a662..21cfd80a 100644 --- a/man/PlotACC.Rd +++ b/man/PlotACC.Rd @@ -13,7 +13,7 @@ PlotACC(ACC, sdates, toptitle = "", sizetit = 1, ytitle = "", limits = NULL, legends = NULL, freq = 12, biglab = FALSE, fill = FALSE, linezero = FALSE, points = TRUE, vlines = NULL, fileout = "output_PlotACC.eps", - width = 8, height = 5, units = 'in', res = 100, ...) + width = 8, height = 5, size_units = 'in', res = 100, ...) } \arguments{ \item{ACC}{ @@ -64,12 +64,12 @@ and tiff. \cr Default = 'output_PlotACC.eps' } \item{width}{ -File width, in the units specified in the parameter units (inches by default). Takes 8 by default. +File width, in the units specified in the parameter size_units (inches by default). Takes 8 by default. } \item{height}{ -File height, in the units specified in the parameter units (inches by default). Takes 5 by default. +File height, in the units specified in the parameter size_units (inches by default). Takes 5 by default. } - \item{units}{ + \item{size_units}{ Units of the size of the device (file or window) to plot in. Inches ('in') by default. See ?Devices and the creator function of the corresponding device. } \item{res}{ diff --git a/man/PlotAno.Rd b/man/PlotAno.Rd index 6a8cbf25..3a97572a 100644 --- a/man/PlotAno.Rd +++ b/man/PlotAno.Rd @@ -16,7 +16,7 @@ PlotAno(exp_ano, obs_ano = NULL, sdates, toptitle = c("", "", "", "", "", "", ensmean = TRUE, linezero = FALSE, points = FALSE, vlines = NULL, fileout = c("output1_plotano.eps", "output2_plotano.eps", "output3_plotano.eps", "output4_plotano.eps", "output5_plotano.eps"), - sizetit = 1, width = 8, height = 5, units = 'in', res = 100, ...) + sizetit = 1, width = 8, height = 5, size_units = 'in', res = 100, ...) } \arguments{ \item{exp_ano}{ @@ -80,12 +80,12 @@ Default = c('output1_plotano.eps', 'output2_plotano.eps', 'output5_plotano.eps') } \item{width}{ -File width, in the units specified in the parameter units (inches by default). Takes 8 by default. +File width, in the units specified in the parameter size_units (inches by default). Takes 8 by default. } \item{height}{ -File height, in the units specified in the parameter units (inches by default). Takes 5 by default. +File height, in the units specified in the parameter size_units (inches by default). Takes 5 by default. } - \item{units}{ + \item{size_units}{ Units of the size of the device (file or window) to plot in. Inches ('in') by default. See ?Devices and the creator function of the corresponding device. } \item{res}{ diff --git a/man/PlotBoxWhisker.Rd b/man/PlotBoxWhisker.Rd index 4129aa59..973f1d38 100644 --- a/man/PlotBoxWhisker.Rd +++ b/man/PlotBoxWhisker.Rd @@ -12,7 +12,7 @@ n-monthly to n-yearly time series. \usage{ PlotBoxWhisker(exp, obs, toptitle = '', ytitle = '', monini = 1, yearini = 0, freq = 1, expname = "exp 1", obsname = "obs 1", drawleg = TRUE, - width = 8, height = 5, units = 'in', res = 100, + width = 8, height = 5, size_units = 'in', res = 100, fileout = "output_PlotBoxWhisker.ps", ...) } \arguments{ @@ -61,12 +61,12 @@ and tiff. \cr Default = 'output_PlotBox.ps' } \item{width}{ -File width, in the units specified in the parameter units (inches by default). Takes 8 by default. +File width, in the units specified in the parameter size_units (inches by default). Takes 8 by default. } \item{height}{ -File height, in the units specified in the parameter units (inches by default). Takes 5 by default. +File height, in the units specified in the parameter size_units (inches by default). Takes 5 by default. } - \item{units}{ + \item{size_units}{ Units of the size of the device (file or window) to plot in. Inches ('in') by default. See ?Devices and the creator function of the corresponding device. } \item{res}{ diff --git a/man/PlotClim.Rd b/man/PlotClim.Rd index 7c796ba4..b2aa7341 100644 --- a/man/PlotClim.Rd +++ b/man/PlotClim.Rd @@ -12,7 +12,7 @@ Plots climatologies as a function of the forecast time for any index output from PlotClim(exp_clim, obs_clim = NULL, toptitle = "", ytitle = "", monini = 1, freq = 12, limits = NULL, listexp = c("exp1", "exp2", "exp3"), listobs = c("obs1", "obs2", "obs3"), biglab = FALSE, leg = TRUE, - sizetit = 1, width = 8, height = 5, units = 'in', res = 100, + sizetit = 1, width = 8, height = 5, size_units = 'in', res = 100, fileout = "output_plotclim.eps", ...) } \arguments{ @@ -55,12 +55,12 @@ TRUE/FALSE to plot the legend or not. Multiplicative factor to scale title size, optional. } \item{width}{ -File width, in the units specified in the parameter units (inches by default). Takes 8 by default. +File width, in the units specified in the parameter size_units (inches by default). Takes 8 by default. } \item{height}{ -File height, in the units specified in the parameter units (inches by default). Takes 5 by default. +File height, in the units specified in the parameter size_units (inches by default). Takes 5 by default. } - \item{units}{ + \item{size_units}{ Units of the size of the device (file or window) to plot in. Inches ('in') by default. See ?Devices and the creator function of the corresponding device. } \item{res}{ diff --git a/man/PlotEquiMap.Rd b/man/PlotEquiMap.Rd index ac4792ab..9ba2ca49 100644 --- a/man/PlotEquiMap.Rd +++ b/man/PlotEquiMap.Rd @@ -33,7 +33,7 @@ PlotEquiMap(var, lon, lat, varu = NULL, varv = NULL, boxlim = NULL, boxcol = 'purple2', boxlwd = 5, margin_scale = rep(1, 4), title_scale = 1, numbfig = NULL, fileout = NULL, - width = 8, height = 5, units = 'in', res = 100, ...) + width = 8, height = 5, size_units = 'in', res = 100, ...) } \arguments{ \item{var}{ @@ -172,12 +172,12 @@ Number of figures in the layout the plot will be put into. A higher numbfig will File where to save the plot. If not specified (default) a graphics device will pop up. Extensions allowed: eps/ps, jpeg, png, pdf, bmp and tiff. \cr } \item{width}{ -File width, in the units specified in the parameter units (inches by default). Takes 8 by default. +File width, in the units specified in the parameter size_units (inches by default). Takes 8 by default. } \item{height}{ -File height, in the units specified in the parameter units (inches by default). Takes 5 by default. +File height, in the units specified in the parameter size_units (inches by default). Takes 5 by default. } - \item{units}{ + \item{size_units}{ Units of the size of the device (file or window) to plot in. Inches ('in') by default. See ?Devices and the creator function of the corresponding device. } \item{res}{ diff --git a/man/PlotLayout.Rd b/man/PlotLayout.Rd index c64a46aa..c36e7fdb 100644 --- a/man/PlotLayout.Rd +++ b/man/PlotLayout.Rd @@ -25,7 +25,7 @@ PlotLayout(fun, plot_dims, var, ..., special_args = NULL, bar_left_shift_scale = 1, bar_label_digits = 4, extra_margin = rep(0, 4), fileout = NULL, width = NULL, height = NULL, - units = 'in', res = 100, close_device = TRUE) + size_units = 'in', res = 100, close_device = TRUE) } \arguments{ \item{fun}{ @@ -113,7 +113,7 @@ Width in inches of the multi-pannel. 7 by default, or 11 if 'fielout' has been s \item{height}{ Height in inches of the multi-pannel. 7 by default, or 11 if 'fileout' has been specified. } - \item{units}{ + \item{size_units}{ Units of the size of the device (file or window) to plot in. Inches ('in') by default. See ?Devices and the creator function of the corresponding device. } \item{res}{ diff --git a/man/PlotSection.Rd b/man/PlotSection.Rd index 0bb19fa9..846cdf0e 100644 --- a/man/PlotSection.Rd +++ b/man/PlotSection.Rd @@ -10,7 +10,7 @@ Plot a (longitude,depth) or (latitude,depth) section. PlotSection(var, horiz, depth, toptitle = "", sizetit = 1, units = "", brks = NULL, cols = NULL, axelab = TRUE, intydep = 200, intxhoriz = 20, drawleg = TRUE, - width = 8, height = 5, units = 'in', res = 100, + width = 8, height = 5, size_units = 'in', res = 100, fileout = NULL, ...) } \arguments{ @@ -52,12 +52,12 @@ Default: 20deg. Draw colorbar. Default: TRUE. } \item{width}{ -File width, in the units specified in the parameter units (inches by default). Takes 8 by default. +File width, in the units specified in the parameter size_units (inches by default). Takes 8 by default. } \item{height}{ -File height, in the units specified in the parameter units (inches by default). Takes 5 by default. +File height, in the units specified in the parameter size_units (inches by default). Takes 5 by default. } - \item{units}{ + \item{size_units}{ Units of the size of the device (file or window) to plot in. Inches ('in') by default. See ?Devices and the creator function of the corresponding device. } \item{res}{ diff --git a/man/PlotStereoMap.Rd b/man/PlotStereoMap.Rd index 22105e83..b7cf995d 100644 --- a/man/PlotStereoMap.Rd +++ b/man/PlotStereoMap.Rd @@ -24,7 +24,7 @@ PlotStereoMap(var, lon, lat, latlims = c(60, 90), bar_extra_margin = rep(0, 4), boxlim = NULL, boxcol = "purple2", boxlwd = 5, margin_scale = rep(1, 4), title_scale = 1, - numbfig = NULL, width = 8, height = 5, units = 'in', res = 100, + numbfig = NULL, width = 8, height = 5, size_units = 'in', res = 100, fileout = NULL, ...) } \arguments{ @@ -106,12 +106,12 @@ Number of figures in the layout the plot will be put into. A higher numbfig will File where to save the plot. If not specified (default) a graphics device will pop up. Extensions allowed: eps/ps, jpeg, png, pdf, bmp and tiff. \cr } \item{width}{ -File width, in the units specified in the parameter units (inches by default). Takes 8 by default. +File width, in the units specified in the parameter size_units (inches by default). Takes 8 by default. } \item{height}{ -File height, in the units specified in the parameter units (inches by default). Takes 5 by default. +File height, in the units specified in the parameter size_units (inches by default). Takes 5 by default. } - \item{units}{ + \item{size_units}{ Units of the size of the device (file or window) to plot in. Inches ('in') by default. See ?Devices and the creator function of the corresponding device. } \item{res}{ diff --git a/man/PlotVsLTime.Rd b/man/PlotVsLTime.Rd index ee0417c4..cebb9e50 100644 --- a/man/PlotVsLTime.Rd +++ b/man/PlotVsLTime.Rd @@ -12,7 +12,7 @@ PlotVsLTime(var, toptitle = "", ytitle = "", monini = 1, freq = 12, listobs = c("obs1", "obs2", "obs3"), biglab = FALSE, hlines = NULL, leg = TRUE, siglev = FALSE, sizetit = 1, show_conf = TRUE, fileout = "output_plotvsltime.eps", - width = 8, height = 5, units = 'in', res = 100, ...) + width = 8, height = 5, size_units = 'in', res = 100, ...) } \arguments{ \item{var}{ @@ -70,12 +70,12 @@ and tiff.\cr Default = 'output_plotvsltime.eps' } \item{width}{ -File width, in the units specified in the parameter units (inches by default). Takes 8 by default. +File width, in the units specified in the parameter size_units (inches by default). Takes 8 by default. } \item{height}{ -File height, in the units specified in the parameter units (inches by default). Takes 5 by default. +File height, in the units specified in the parameter size_units (inches by default). Takes 5 by default. } - \item{units}{ + \item{size_units}{ Units of the size of the device (file or window) to plot in. Inches ('in') by default. See ?Devices and the creator function of the corresponding device. } \item{res}{ -- GitLab From bb9c7efcbdc7c9799d18a57db8931e4cfd33e76f Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Wed, 28 Sep 2016 16:25:41 +0200 Subject: [PATCH 04/11] Small fix. --- R/Utils.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/Utils.R b/R/Utils.R index c2dd015b..957a196c 100644 --- a/R/Utils.R +++ b/R/Utils.R @@ -1131,7 +1131,7 @@ # If there is an extension specified, select the correct device ## units of width and height set to accept inches if (ext[1] == ".png") { - saveToFile png + saveToFile <- png } else if (ext[1] == ".jpeg") { saveToFile <- jpeg } else if (ext[1] == ".eps") { -- GitLab From 2732de2962c1f9a617a6f13e91342f3f6944a4d8 Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Wed, 28 Sep 2016 16:38:56 +0200 Subject: [PATCH 05/11] Some fixes. --- man/Plot2VarsVsLTime.Rd | 2 +- man/PlotAno.Rd | 4 ++-- man/PlotBoxWhisker.Rd | 4 ++-- man/PlotClim.Rd | 4 ++-- man/PlotSection.Rd | 5 ++--- man/PlotStereoMap.Rd | 4 ++-- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/man/Plot2VarsVsLTime.Rd b/man/Plot2VarsVsLTime.Rd index 68a85f9c..96e9c0c4 100644 --- a/man/Plot2VarsVsLTime.Rd +++ b/man/Plot2VarsVsLTime.Rd @@ -15,7 +15,7 @@ Plot2VarsVsLTime(var1, var2, toptitle = "", ytitle = "", monini = 1, listvars = c("var1", "var2"), biglab = FALSE, hlines = NULL, leg = TRUE, siglev = FALSE, sizetit = 1, show_conf = TRUE, fileout = "output_plot2varsvsltime.eps", - width = 8, height = 5, units = 'in', res = 100, ...) + width = 8, height = 5, size_units = 'in', res = 100, ...) } \arguments{ \item{var1}{ diff --git a/man/PlotAno.Rd b/man/PlotAno.Rd index 3a97572a..ec3d6de7 100644 --- a/man/PlotAno.Rd +++ b/man/PlotAno.Rd @@ -14,9 +14,9 @@ PlotAno(exp_ano, obs_ano = NULL, sdates, toptitle = c("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""), limits = NULL, legends = NULL, freq = 12, biglab = FALSE, fill = TRUE, memb = TRUE, ensmean = TRUE, linezero = FALSE, points = FALSE, vlines = NULL, - fileout = c("output1_plotano.eps", "output2_plotano.eps", + sizetit = 1, fileout = c("output1_plotano.eps", "output2_plotano.eps", "output3_plotano.eps", "output4_plotano.eps", "output5_plotano.eps"), - sizetit = 1, width = 8, height = 5, size_units = 'in', res = 100, ...) + width = 8, height = 5, size_units = 'in', res = 100, ...) } \arguments{ \item{exp_ano}{ diff --git a/man/PlotBoxWhisker.Rd b/man/PlotBoxWhisker.Rd index 973f1d38..31d11d9e 100644 --- a/man/PlotBoxWhisker.Rd +++ b/man/PlotBoxWhisker.Rd @@ -12,8 +12,8 @@ n-monthly to n-yearly time series. \usage{ PlotBoxWhisker(exp, obs, toptitle = '', ytitle = '', monini = 1, yearini = 0, freq = 1, expname = "exp 1", obsname = "obs 1", drawleg = TRUE, - width = 8, height = 5, size_units = 'in', res = 100, - fileout = "output_PlotBoxWhisker.ps", ...) + fileout = "output_PlotBoxWhisker.ps", + width = 8, height = 5, size_units = 'in', res = 100, ...) } \arguments{ \item{exp}{ diff --git a/man/PlotClim.Rd b/man/PlotClim.Rd index b2aa7341..68403866 100644 --- a/man/PlotClim.Rd +++ b/man/PlotClim.Rd @@ -12,8 +12,8 @@ Plots climatologies as a function of the forecast time for any index output from PlotClim(exp_clim, obs_clim = NULL, toptitle = "", ytitle = "", monini = 1, freq = 12, limits = NULL, listexp = c("exp1", "exp2", "exp3"), listobs = c("obs1", "obs2", "obs3"), biglab = FALSE, leg = TRUE, - sizetit = 1, width = 8, height = 5, size_units = 'in', res = 100, - fileout = "output_plotclim.eps", ...) + sizetit = 1, fileout = "output_plotclim.eps", + width = 8, height = 5, size_units = 'in', res = 100, ...) } \arguments{ \item{exp_clim}{ diff --git a/man/PlotSection.Rd b/man/PlotSection.Rd index 846cdf0e..f7f3349f 100644 --- a/man/PlotSection.Rd +++ b/man/PlotSection.Rd @@ -9,9 +9,8 @@ Plot a (longitude,depth) or (latitude,depth) section. \usage{ PlotSection(var, horiz, depth, toptitle = "", sizetit = 1, units = "", brks = NULL, cols = NULL, axelab = TRUE, intydep = 200, - intxhoriz = 20, drawleg = TRUE, - width = 8, height = 5, size_units = 'in', res = 100, - fileout = NULL, ...) + intxhoriz = 20, drawleg = TRUE, fileout = NULL, + width = 8, height = 5, size_units = 'in', res = 100, ...) } \arguments{ \item{var}{ diff --git a/man/PlotStereoMap.Rd b/man/PlotStereoMap.Rd index b7cf995d..32478843 100644 --- a/man/PlotStereoMap.Rd +++ b/man/PlotStereoMap.Rd @@ -24,8 +24,8 @@ PlotStereoMap(var, lon, lat, latlims = c(60, 90), bar_extra_margin = rep(0, 4), boxlim = NULL, boxcol = "purple2", boxlwd = 5, margin_scale = rep(1, 4), title_scale = 1, - numbfig = NULL, width = 8, height = 5, size_units = 'in', res = 100, - fileout = NULL, ...) + numbfig = NULL, fileout = NULL, width = 8, height = 5, + size_units = 'in', res = 100, ...) } \arguments{ \item{var}{ -- GitLab From 7e052e84d588bc3d5aee2c419fa1b938e59f97e2 Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Wed, 28 Sep 2016 16:45:53 +0200 Subject: [PATCH 06/11] Some fixes. --- R/Plot2VarsVsLTime.R | 2 +- R/PlotACC.R | 2 +- R/PlotAno.R | 2 +- R/PlotBoxWhisker.R | 2 +- R/PlotClim.R | 2 +- R/PlotEquiMap.R | 2 +- R/PlotSection.R | 2 +- R/PlotStereoMap.R | 2 +- R/PlotVsLTime.R | 2 +- man/Plot2VarsVsLTime.Rd | 6 +++--- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/R/Plot2VarsVsLTime.R b/R/Plot2VarsVsLTime.R index 1a55500e..b176fb17 100644 --- a/R/Plot2VarsVsLTime.R +++ b/R/Plot2VarsVsLTime.R @@ -101,7 +101,7 @@ Plot2VarsVsLTime <- function(var1, var2, toptitle = '', ytitle = '', monini = 1, if (!is.null(fileout)) { saveToFile(fileout, units = size_units, res = res, width = width, height = height) - } else if (names(dev.curr()) == 'null device') { + } else if (names(dev.cur()) == 'null device') { dev.new(units = size_units, res = res, width = width, height = height) } diff --git a/R/PlotACC.R b/R/PlotACC.R index 84104ffd..bbce860f 100644 --- a/R/PlotACC.R +++ b/R/PlotACC.R @@ -55,7 +55,7 @@ PlotACC <- function(ACC, sdates, toptitle = "", sizetit = 1, ytitle = "", if (!is.null(fileout)) { saveToFile(fileout, units = size_units, res = res, width = width, height = height) - } else if (names(dev.curr()) == 'null device') { + } else if (names(dev.cur()) == 'null device') { dev.new(units = size_units, res = res, width = width, height = height) } diff --git a/R/PlotAno.R b/R/PlotAno.R index 615240d4..766e6ae1 100644 --- a/R/PlotAno.R +++ b/R/PlotAno.R @@ -105,7 +105,7 @@ PlotAno <- function(exp_ano, obs_ano = NULL, sdates, if (!is.null(fileout)) { saveToFile(fileout[jexp], units = size_units, res = res, width = width, height = height) - } else if (names(dev.curr()) == 'null device') { + } else if (names(dev.cur()) == 'null device') { dev.new(units = size_units, res = res, width = width, height = height) } diff --git a/R/PlotBoxWhisker.R b/R/PlotBoxWhisker.R index 5eede493..76467264 100644 --- a/R/PlotBoxWhisker.R +++ b/R/PlotBoxWhisker.R @@ -95,7 +95,7 @@ PlotBoxWhisker <- function(exp, obs, toptitle = '', ytitle = '', monini = 1, if (!is.null(fileout)) { saveToFile(fileout, units = size_units, res = res, width = width, height = height) - } else if (names(dev.curr()) == 'null device') { + } else if (names(dev.cur()) == 'null device') { dev.new(units = size_units, res = res, width = width, height = height) } diff --git a/R/PlotClim.R b/R/PlotClim.R index f88eadd1..4260c3b6 100644 --- a/R/PlotClim.R +++ b/R/PlotClim.R @@ -93,7 +93,7 @@ PlotClim <- function(exp_clim, obs_clim = NULL, toptitle = '', ytitle = '', if (!is.null(fileout)) { saveToFile(fileout, units = size_units, res = res, width = width, height = height) - } else if (names(dev.curr()) == 'null device') { + } else if (names(dev.cur()) == 'null device') { dev.new(units = size_units, res = res, width = width, height = height) } diff --git a/R/PlotEquiMap.R b/R/PlotEquiMap.R index deaf055c..d32c6e2e 100644 --- a/R/PlotEquiMap.R +++ b/R/PlotEquiMap.R @@ -407,7 +407,7 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, if (!is.null(fileout)) { saveToFile(fileout, units = size_units, res = res, width = width, height = height) - } else if (names(dev.curr()) == 'null device') { + } else if (names(dev.cur()) == 'null device') { dev.new(units = size_units, res = res, width = width, height = height) } diff --git a/R/PlotSection.R b/R/PlotSection.R index ac21ae26..9a56a99d 100644 --- a/R/PlotSection.R +++ b/R/PlotSection.R @@ -71,7 +71,7 @@ PlotSection <- function(var, horiz, depth, toptitle = '', sizetit = 1, if (!is.null(fileout)) { saveToFile(fileout, units = size_units, res = res, width = width, height = height) - } else if (names(dev.curr()) == 'null device') { + } else if (names(dev.cur()) == 'null device') { dev.new(units = size_units, res = res, width = width, height = height) } diff --git a/R/PlotStereoMap.R b/R/PlotStereoMap.R index 6fc47536..6a2f118e 100644 --- a/R/PlotStereoMap.R +++ b/R/PlotStereoMap.R @@ -261,7 +261,7 @@ PlotStereoMap <- function(var, lon, lat, latlims = c(60, 90), if (!is.null(fileout)) { saveToFile(fileout, units = size_units, res = res, width = width, height = height) - } else if (names(dev.curr()) == 'null device') { + } else if (names(dev.cur()) == 'null device') { dev.new(units = size_units, res = res, width = width, height = height) } diff --git a/R/PlotVsLTime.R b/R/PlotVsLTime.R index 6b168483..2eea76d0 100644 --- a/R/PlotVsLTime.R +++ b/R/PlotVsLTime.R @@ -92,7 +92,7 @@ PlotVsLTime <- function(var, toptitle = '', ytitle = '', monini = 1, freq = 12, if (!is.null(fileout)) { saveToFile(fileout, units = size_units, res = res, width = width, height = height) - } else if (names(dev.curr()) == 'null device') { + } else if (names(dev.cur()) == 'null device') { dev.new(units = size_units, res = res, width = width, height = height) } diff --git a/man/Plot2VarsVsLTime.Rd b/man/Plot2VarsVsLTime.Rd index 96e9c0c4..faeaed79 100644 --- a/man/Plot2VarsVsLTime.Rd +++ b/man/Plot2VarsVsLTime.Rd @@ -74,12 +74,12 @@ and tiff. \cr Default = 'output_plot2varsvsltime.eps' } \item{width}{ -File width, in the units specified in the parameter units (inches by default). Takes 8 by default. +File width, in the units specified in the parameter size_units (inches by default). Takes 8 by default. } \item{height}{ -File height, in the units specified in the parameter units (inches by default). Takes 5 by default. +File height, in the units specified in the parameter size_units (inches by default). Takes 5 by default. } - \item{units}{ + \item{size_units}{ Units of the size of the device (file or window) to plot in. Inches ('in') by default. See ?Devices and the creator function of the corresponding device. } \item{res}{ -- GitLab From 30717e92efed4e22651d03eba7c099735171496b Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Wed, 28 Sep 2016 17:08:56 +0200 Subject: [PATCH 07/11] Some more fixes. --- R/Plot2VarsVsLTime.R | 5 ++--- R/PlotACC.R | 5 ++--- R/PlotAno.R | 5 ++--- R/PlotBoxWhisker.R | 5 ++--- R/PlotClim.R | 5 ++--- R/PlotEquiMap.R | 5 ++--- R/PlotLayout.R | 5 ++--- R/PlotSection.R | 5 ++--- R/PlotStereoMap.R | 5 ++--- R/PlotVsLTime.R | 5 ++--- R/Utils.R | 18 +++++++++++++----- 11 files changed, 33 insertions(+), 35 deletions(-) diff --git a/R/Plot2VarsVsLTime.R b/R/Plot2VarsVsLTime.R index b176fb17..80735fad 100644 --- a/R/Plot2VarsVsLTime.R +++ b/R/Plot2VarsVsLTime.R @@ -13,7 +13,7 @@ Plot2VarsVsLTime <- function(var1, var2, toptitle = '', ytitle = '', monini = 1, # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { - deviceInfo <- .SelectDevice(fileout) + deviceInfo <- .SelectDevice(fileout, width = width, height = height, units = size_units, res = res) saveToFile <- deviceInfo$fun fileout <- deviceInfo$files } @@ -99,8 +99,7 @@ Plot2VarsVsLTime <- function(var1, var2, toptitle = '', ytitle = '', monini = 1, # Open connection to graphical device if (!is.null(fileout)) { - saveToFile(fileout, units = size_units, res = res, - width = width, height = height) + saveToFile(fileout) } else if (names(dev.cur()) == 'null device') { dev.new(units = size_units, res = res, width = width, height = height) } diff --git a/R/PlotACC.R b/R/PlotACC.R index bbce860f..157015cb 100644 --- a/R/PlotACC.R +++ b/R/PlotACC.R @@ -11,7 +11,7 @@ PlotACC <- function(ACC, sdates, toptitle = "", sizetit = 1, ytitle = "", # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { - deviceInfo <- .SelectDevice(fileout) + deviceInfo <- .SelectDevice(fileout, width = width, height = height, units = size_units, res = res) saveToFile <- deviceInfo$fun fileout <- deviceInfo$files } @@ -53,8 +53,7 @@ PlotACC <- function(ACC, sdates, toptitle = "", sizetit = 1, ytitle = "", # Open connection to graphical device if (!is.null(fileout)) { - saveToFile(fileout, units = size_units, res = res, - width = width, height = height) + saveToFile(fileout) } else if (names(dev.cur()) == 'null device') { dev.new(units = size_units, res = res, width = width, height = height) } diff --git a/R/PlotAno.R b/R/PlotAno.R index 766e6ae1..2b717536 100644 --- a/R/PlotAno.R +++ b/R/PlotAno.R @@ -18,7 +18,7 @@ PlotAno <- function(exp_ano, obs_ano = NULL, sdates, # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { - deviceInfo <- .SelectDevice(fileout) + deviceInfo <- .SelectDevice(fileout, width = width, height = height, units = size_units, res = res) saveToFile <- deviceInfo$fun fileout <- deviceInfo$files } @@ -103,8 +103,7 @@ PlotAno <- function(exp_ano, obs_ano = NULL, sdates, # Open connection to graphical device if (!is.null(fileout)) { - saveToFile(fileout[jexp], units = size_units, res = res, - width = width, height = height) + saveToFile(fileout[jexp]) } else if (names(dev.cur()) == 'null device') { dev.new(units = size_units, res = res, width = width, height = height) } diff --git a/R/PlotBoxWhisker.R b/R/PlotBoxWhisker.R index 76467264..dfd926b0 100644 --- a/R/PlotBoxWhisker.R +++ b/R/PlotBoxWhisker.R @@ -12,7 +12,7 @@ PlotBoxWhisker <- function(exp, obs, toptitle = '', ytitle = '', monini = 1, # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { - deviceInfo <- .SelectDevice(fileout) + deviceInfo <- .SelectDevice(fileout, width = width, height = height, units = size_units, res = res) saveToFile <- deviceInfo$fun fileout <- deviceInfo$files } @@ -93,8 +93,7 @@ PlotBoxWhisker <- function(exp, obs, toptitle = '', ytitle = '', monini = 1, # Open connection to graphical device if (!is.null(fileout)) { - saveToFile(fileout, units = size_units, res = res, - width = width, height = height) + saveToFile(fileout) } else if (names(dev.cur()) == 'null device') { dev.new(units = size_units, res = res, width = width, height = height) } diff --git a/R/PlotClim.R b/R/PlotClim.R index 4260c3b6..d6dfb9a6 100644 --- a/R/PlotClim.R +++ b/R/PlotClim.R @@ -12,7 +12,7 @@ PlotClim <- function(exp_clim, obs_clim = NULL, toptitle = '', ytitle = '', # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { - deviceInfo <- .SelectDevice(fileout) + deviceInfo <- .SelectDevice(fileout, width = width, height = height, units = size_units, res = res) saveToFile <- deviceInfo$fun fileout <- deviceInfo$files } @@ -91,8 +91,7 @@ PlotClim <- function(exp_clim, obs_clim = NULL, toptitle = '', ytitle = '', # Open connection to graphical device if (!is.null(fileout)) { - saveToFile(fileout, units = size_units, res = res, - width = width, height = height) + saveToFile(fileout) } else if (names(dev.cur()) == 'null device') { dev.new(units = size_units, res = res, width = width, height = height) } diff --git a/R/PlotEquiMap.R b/R/PlotEquiMap.R index d32c6e2e..beb53b47 100644 --- a/R/PlotEquiMap.R +++ b/R/PlotEquiMap.R @@ -34,7 +34,7 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { - deviceInfo <- .SelectDevice(fileout) + deviceInfo <- .SelectDevice(fileout, width = width, height = height, units = size_units, res = res) saveToFile <- deviceInfo$fun fileout <- deviceInfo$files } @@ -405,8 +405,7 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, # Open connection to graphical device if (!is.null(fileout)) { - saveToFile(fileout, units = size_units, res = res, - width = width, height = height) + saveToFile(fileout) } else if (names(dev.cur()) == 'null device') { dev.new(units = size_units, res = res, width = width, height = height) } diff --git a/R/PlotLayout.R b/R/PlotLayout.R index d179c48a..5bcc2bf3 100644 --- a/R/PlotLayout.R +++ b/R/PlotLayout.R @@ -19,7 +19,7 @@ PlotLayout <- function(fun, plot_dims, var, ..., special_args = NULL, # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { - deviceInfo <- .SelectDevice(fileout) + deviceInfo <- .SelectDevice(fileout, width = width, height = height, units = size_units, res = res) saveToFile <- deviceInfo$fun fileout <- deviceInfo$files } @@ -280,8 +280,7 @@ PlotLayout <- function(fun, plot_dims, var, ..., special_args = NULL, # Open connection to graphical device if (!is.null(fileout)) { - saveToFile(fileout, units = size_units, res = res, - width = width, height = height) + saveToFile(fileout) } else if (names(dev.cur()) == 'null device') { dev.new(units = size_units, res = res, width = width, height = height) } else if (prod(par('mfrow')) > 1) { diff --git a/R/PlotSection.R b/R/PlotSection.R index 9a56a99d..9949ac3c 100644 --- a/R/PlotSection.R +++ b/R/PlotSection.R @@ -11,7 +11,7 @@ PlotSection <- function(var, horiz, depth, toptitle = '', sizetit = 1, # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { - deviceInfo <- .SelectDevice(fileout) + deviceInfo <- .SelectDevice(fileout, width = width, height = height, units = size_units, res = res) saveToFile <- deviceInfo$fun fileout <- deviceInfo$files } @@ -69,8 +69,7 @@ PlotSection <- function(var, horiz, depth, toptitle = '', sizetit = 1, # Open connection to graphical device if (!is.null(fileout)) { - saveToFile(fileout, units = size_units, res = res, - width = width, height = height) + saveToFile(fileout) } else if (names(dev.cur()) == 'null device') { dev.new(units = size_units, res = res, width = width, height = height) } diff --git a/R/PlotStereoMap.R b/R/PlotStereoMap.R index 6a2f118e..7881f37b 100644 --- a/R/PlotStereoMap.R +++ b/R/PlotStereoMap.R @@ -26,7 +26,7 @@ PlotStereoMap <- function(var, lon, lat, latlims = c(60, 90), # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { - deviceInfo <- .SelectDevice(fileout) + deviceInfo <- .SelectDevice(fileout, width = width, height = height, units = size_units, res = res) saveToFile <- deviceInfo$fun fileout <- deviceInfo$files } @@ -259,8 +259,7 @@ PlotStereoMap <- function(var, lon, lat, latlims = c(60, 90), # Open connection to graphical device if (!is.null(fileout)) { - saveToFile(fileout, units = size_units, res = res, - width = width, height = height) + saveToFile(fileout) } else if (names(dev.cur()) == 'null device') { dev.new(units = size_units, res = res, width = width, height = height) } diff --git a/R/PlotVsLTime.R b/R/PlotVsLTime.R index 2eea76d0..e199eae5 100644 --- a/R/PlotVsLTime.R +++ b/R/PlotVsLTime.R @@ -13,7 +13,7 @@ PlotVsLTime <- function(var, toptitle = '', ytitle = '', monini = 1, freq = 12, # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { - deviceInfo <- .SelectDevice(fileout) + deviceInfo <- .SelectDevice(fileout, width = width, height = height, units = size_units, res = res) saveToFile <- deviceInfo$fun fileout <- deviceInfo$files } @@ -90,8 +90,7 @@ PlotVsLTime <- function(var, toptitle = '', ytitle = '', monini = 1, freq = 12, # Open connection to graphical device if (!is.null(fileout)) { - saveToFile(fileout, units = size_units, res = res, - width = width, height = height) + saveToFile(fileout) } else if (names(dev.cur()) == 'null device') { dev.new(units = size_units, res = res, width = width, height = height) } diff --git a/R/Utils.R b/R/Utils.R index 957a196c..45db8ff1 100644 --- a/R/Utils.R +++ b/R/Utils.R @@ -1116,7 +1116,7 @@ userArgs } -.SelectDevice <- function(fileout) { +.SelectDevice <- function(fileout, width, height, units, res) { # This function is used in the plot functions to check the extension of the # files where the graphics will be stored and select the right R device to # save them. @@ -1131,9 +1131,13 @@ # If there is an extension specified, select the correct device ## units of width and height set to accept inches if (ext[1] == ".png") { - saveToFile <- png + saveToFile <- function(...) { + png(units = units, res = res, ...) + } } else if (ext[1] == ".jpeg") { - saveToFile <- jpeg + saveToFile <- function(...) { + jpeg(units = units, res = res, ...) + } } else if (ext[1] == ".eps") { saveToFile <- postscript } else if (ext[1] == ".ps") { @@ -1143,9 +1147,13 @@ } else if (ext[1] == ".svg") { saveToFile <- svg } else if (ext[1] == ".bmp") { - saveToFile <- bmp + saveToFile <- function(...) { + bmp(units = units, res = res, ...) + } } else if (ext[1] == ".tiff") { - saveToFile <- tiff + saveToFile <- function(...) { + tiff(units = units, res = res, ...) + } } else { .warning("file extension not supported, it will be used '.eps' by default.") ## In case there is only one filename -- GitLab From ae754b718404d41f0c3d4fc91c56e44c05394468 Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Wed, 28 Sep 2016 18:14:48 +0200 Subject: [PATCH 08/11] Some fixes. --- .gitignore | 1 + R/Plot2VarsVsLTime.R | 2 +- R/PlotACC.R | 2 +- R/PlotAno.R | 2 +- R/PlotBoxWhisker.R | 2 +- R/PlotClim.R | 2 +- R/PlotEquiMap.R | 2 +- R/PlotLayout.R | 2 +- R/PlotSection.R | 2 +- R/PlotStereoMap.R | 2 +- R/PlotVsLTime.R | 2 +- R/Utils.R | 36 +++++++++++++++++++++--------------- 12 files changed, 32 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index d03a49e6..ff0a6619 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ master_pull.txt *.ps *.gif *.png +*.jpeg Rplots.pdf diff --git a/R/Plot2VarsVsLTime.R b/R/Plot2VarsVsLTime.R index 80735fad..b23a25ad 100644 --- a/R/Plot2VarsVsLTime.R +++ b/R/Plot2VarsVsLTime.R @@ -13,7 +13,7 @@ Plot2VarsVsLTime <- function(var1, var2, toptitle = '', ytitle = '', monini = 1, # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { - deviceInfo <- .SelectDevice(fileout, width = width, height = height, units = size_units, res = res) + deviceInfo <- .SelectDevice(fileout = fileout, width = width, height = height, units = size_units, res = res) saveToFile <- deviceInfo$fun fileout <- deviceInfo$files } diff --git a/R/PlotACC.R b/R/PlotACC.R index 157015cb..3f499e71 100644 --- a/R/PlotACC.R +++ b/R/PlotACC.R @@ -11,7 +11,7 @@ PlotACC <- function(ACC, sdates, toptitle = "", sizetit = 1, ytitle = "", # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { - deviceInfo <- .SelectDevice(fileout, width = width, height = height, units = size_units, res = res) + deviceInfo <- .SelectDevice(fileout = fileout, width = width, height = height, units = size_units, res = res) saveToFile <- deviceInfo$fun fileout <- deviceInfo$files } diff --git a/R/PlotAno.R b/R/PlotAno.R index 2b717536..450f31d8 100644 --- a/R/PlotAno.R +++ b/R/PlotAno.R @@ -18,7 +18,7 @@ PlotAno <- function(exp_ano, obs_ano = NULL, sdates, # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { - deviceInfo <- .SelectDevice(fileout, width = width, height = height, units = size_units, res = res) + deviceInfo <- .SelectDevice(fileout = fileout, width = width, height = height, units = size_units, res = res) saveToFile <- deviceInfo$fun fileout <- deviceInfo$files } diff --git a/R/PlotBoxWhisker.R b/R/PlotBoxWhisker.R index dfd926b0..1bf41ff1 100644 --- a/R/PlotBoxWhisker.R +++ b/R/PlotBoxWhisker.R @@ -12,7 +12,7 @@ PlotBoxWhisker <- function(exp, obs, toptitle = '', ytitle = '', monini = 1, # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { - deviceInfo <- .SelectDevice(fileout, width = width, height = height, units = size_units, res = res) + deviceInfo <- .SelectDevice(fileout = fileout, width = width, height = height, units = size_units, res = res) saveToFile <- deviceInfo$fun fileout <- deviceInfo$files } diff --git a/R/PlotClim.R b/R/PlotClim.R index d6dfb9a6..7ce30c0d 100644 --- a/R/PlotClim.R +++ b/R/PlotClim.R @@ -12,7 +12,7 @@ PlotClim <- function(exp_clim, obs_clim = NULL, toptitle = '', ytitle = '', # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { - deviceInfo <- .SelectDevice(fileout, width = width, height = height, units = size_units, res = res) + deviceInfo <- .SelectDevice(fileout = fileout, width = width, height = height, units = size_units, res = res) saveToFile <- deviceInfo$fun fileout <- deviceInfo$files } diff --git a/R/PlotEquiMap.R b/R/PlotEquiMap.R index beb53b47..dea625df 100644 --- a/R/PlotEquiMap.R +++ b/R/PlotEquiMap.R @@ -34,7 +34,7 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { - deviceInfo <- .SelectDevice(fileout, width = width, height = height, units = size_units, res = res) + deviceInfo <- .SelectDevice(fileout = fileout, width = width, height = height, units = size_units, res = res) saveToFile <- deviceInfo$fun fileout <- deviceInfo$files } diff --git a/R/PlotLayout.R b/R/PlotLayout.R index 5bcc2bf3..36719d6d 100644 --- a/R/PlotLayout.R +++ b/R/PlotLayout.R @@ -19,7 +19,7 @@ PlotLayout <- function(fun, plot_dims, var, ..., special_args = NULL, # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { - deviceInfo <- .SelectDevice(fileout, width = width, height = height, units = size_units, res = res) + deviceInfo <- .SelectDevice(fileout = fileout, width = width, height = height, units = size_units, res = res) saveToFile <- deviceInfo$fun fileout <- deviceInfo$files } diff --git a/R/PlotSection.R b/R/PlotSection.R index 9949ac3c..acefbdd8 100644 --- a/R/PlotSection.R +++ b/R/PlotSection.R @@ -11,7 +11,7 @@ PlotSection <- function(var, horiz, depth, toptitle = '', sizetit = 1, # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { - deviceInfo <- .SelectDevice(fileout, width = width, height = height, units = size_units, res = res) + deviceInfo <- .SelectDevice(fileout = fileout, width = width, height = height, units = size_units, res = res) saveToFile <- deviceInfo$fun fileout <- deviceInfo$files } diff --git a/R/PlotStereoMap.R b/R/PlotStereoMap.R index 7881f37b..656d5e1b 100644 --- a/R/PlotStereoMap.R +++ b/R/PlotStereoMap.R @@ -26,7 +26,7 @@ PlotStereoMap <- function(var, lon, lat, latlims = c(60, 90), # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { - deviceInfo <- .SelectDevice(fileout, width = width, height = height, units = size_units, res = res) + deviceInfo <- .SelectDevice(fileout = fileout, width = width, height = height, units = size_units, res = res) saveToFile <- deviceInfo$fun fileout <- deviceInfo$files } diff --git a/R/PlotVsLTime.R b/R/PlotVsLTime.R index e199eae5..dd068adc 100644 --- a/R/PlotVsLTime.R +++ b/R/PlotVsLTime.R @@ -13,7 +13,7 @@ PlotVsLTime <- function(var, toptitle = '', ytitle = '', monini = 1, freq = 12, # If there is any filenames to store the graphics, process them # to select the right device if (!is.null(fileout)) { - deviceInfo <- .SelectDevice(fileout, width = width, height = height, units = size_units, res = res) + deviceInfo <- .SelectDevice(fileout = fileout, width = width, height = height, units = size_units, res = res) saveToFile <- deviceInfo$fun fileout <- deviceInfo$files } diff --git a/R/Utils.R b/R/Utils.R index 45db8ff1..f3638e74 100644 --- a/R/Utils.R +++ b/R/Utils.R @@ -1131,35 +1131,41 @@ # If there is an extension specified, select the correct device ## units of width and height set to accept inches if (ext[1] == ".png") { - saveToFile <- function(...) { - png(units = units, res = res, ...) + saveToFile <- function(fileout) { + png(filename = fileout, width = width, height = height, res = res) } } else if (ext[1] == ".jpeg") { - saveToFile <- function(...) { - jpeg(units = units, res = res, ...) + saveToFile <- function(fileout) { + jpeg(filename = fileout, width = width, height = height, res = res) + } + } else if (ext[1] %in% c(".eps", ".ps")) { + saveToFile <- function(fileout) { + postscript(filename = fileout, width = width, height = height, res = res) } - } else if (ext[1] == ".eps") { - saveToFile <- postscript - } else if (ext[1] == ".ps") { - saveToFile <- postscript } else if (ext[1] == ".pdf") { - saveToFile <- pdf + saveToFile <- function(fileout) { + pdf(filename = fileout, width = width, height = height, res = res) + } } else if (ext[1] == ".svg") { - saveToFile <- svg + saveToFile <- function(fileout) { + svg(filename = fileout, width = width, height = height, res = res) + } } else if (ext[1] == ".bmp") { - saveToFile <- function(...) { - bmp(units = units, res = res, ...) + saveToFile <- function(fileout) { + bmp(filename = fileout, width = width, height = height, res = res) } } else if (ext[1] == ".tiff") { - saveToFile <- function(...) { - tiff(units = units, res = res, ...) + saveToFile <- function(fileout) { + tiff(filename = fileout, width = width, height = height, res = res) } } else { .warning("file extension not supported, it will be used '.eps' by default.") ## In case there is only one filename fileout[1] <- sub("\\.[a-zA-Z0-9]*$", ".eps", fileout[1]) ext[1] <- ".eps" - saveToFile <- postscript + saveToFile <- function(fileout) { + postscript(filename = fileout, width = width, height = height, res = res) + } } # Change filenames when necessary if (any(ext != ext[1])) { -- GitLab From 8d4065069b5b761c3d3c20d43109761608f1bb75 Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Wed, 28 Sep 2016 18:23:14 +0200 Subject: [PATCH 09/11] Small fix. --- R/Utils.R | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/R/Utils.R b/R/Utils.R index f3638e74..81362e32 100644 --- a/R/Utils.R +++ b/R/Utils.R @@ -1132,31 +1132,31 @@ ## units of width and height set to accept inches if (ext[1] == ".png") { saveToFile <- function(fileout) { - png(filename = fileout, width = width, height = height, res = res) + png(filename = fileout, width = width, height = height, res = res, units = units) } } else if (ext[1] == ".jpeg") { saveToFile <- function(fileout) { - jpeg(filename = fileout, width = width, height = height, res = res) + jpeg(filename = fileout, width = width, height = height, res = res, units = units) } } else if (ext[1] %in% c(".eps", ".ps")) { saveToFile <- function(fileout) { - postscript(filename = fileout, width = width, height = height, res = res) + postscript(filename = fileout, width = width, height = height) } } else if (ext[1] == ".pdf") { saveToFile <- function(fileout) { - pdf(filename = fileout, width = width, height = height, res = res) + pdf(filename = fileout, width = width, height = height) } } else if (ext[1] == ".svg") { saveToFile <- function(fileout) { - svg(filename = fileout, width = width, height = height, res = res) + svg(filename = fileout, width = width, height = height) } } else if (ext[1] == ".bmp") { saveToFile <- function(fileout) { - bmp(filename = fileout, width = width, height = height, res = res) + bmp(filename = fileout, width = width, height = height, res = res, units = units) } } else if (ext[1] == ".tiff") { saveToFile <- function(fileout) { - tiff(filename = fileout, width = width, height = height, res = res) + tiff(filename = fileout, width = width, height = height, res = res, units = units) } } else { .warning("file extension not supported, it will be used '.eps' by default.") @@ -1164,7 +1164,7 @@ fileout[1] <- sub("\\.[a-zA-Z0-9]*$", ".eps", fileout[1]) ext[1] <- ".eps" saveToFile <- function(fileout) { - postscript(filename = fileout, width = width, height = height, res = res) + postscript(filename = fileout, width = width, height = height) } } # Change filenames when necessary -- GitLab From f6efa0c26188058c35c3b9fe7d67541d28006566 Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Wed, 28 Sep 2016 18:25:54 +0200 Subject: [PATCH 10/11] Small fix. --- R/Utils.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/Utils.R b/R/Utils.R index 81362e32..61ad1779 100644 --- a/R/Utils.R +++ b/R/Utils.R @@ -1140,11 +1140,11 @@ } } else if (ext[1] %in% c(".eps", ".ps")) { saveToFile <- function(fileout) { - postscript(filename = fileout, width = width, height = height) + postscript(file = fileout, width = width, height = height) } } else if (ext[1] == ".pdf") { saveToFile <- function(fileout) { - pdf(filename = fileout, width = width, height = height) + pdf(file = fileout, width = width, height = height) } } else if (ext[1] == ".svg") { saveToFile <- function(fileout) { @@ -1164,7 +1164,7 @@ fileout[1] <- sub("\\.[a-zA-Z0-9]*$", ".eps", fileout[1]) ext[1] <- ".eps" saveToFile <- function(fileout) { - postscript(filename = fileout, width = width, height = height) + postscript(file = fileout, width = width, height = height) } } # Change filenames when necessary -- GitLab From c6e75a6723d5236d8691bb4aca81ab98a4fb1ca1 Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Wed, 28 Sep 2016 18:49:39 +0200 Subject: [PATCH 11/11] Small change in gitignore. --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index ff0a6619..591c8224 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,4 @@ merge_output.txt master_pull.txt *.eps *.ps -*.gif -*.png -*.jpeg Rplots.pdf -- GitLab