R/setGraph.R

Defines functions setGraph

Documented in setGraph

#' Set Graph
#' 
#' Sets up a specific graph on a graphics device.
#' 
#' 
#' @param graphNum the number of the graph.
#' @param layout the layout of the graph.
#' @param noTicks suppress ticks on a specific axis.
#' @return The parameters of the margin of the plot area.
#' @note This function is called using the information generated by
#' \code{setLayout}. It invisibly sets up the graphics device for the next
#' graph.
#' @seealso \code{\link{setLayout}}
#' @keywords dplot
#' @examples
#' \dontrun{
#' # See for examples of setGraph:
#' vignette(topic="BoxPlots", package="smwrGraphs")
#' vignette(topic="GraphGallery", package="smwrGraphs")
#' vignette(topic="GraphSetup", package="smwrGraphs")
#' vignette(topic="PiperPlot", package="smwrGraphs")
#' demo(topic="HydroPrecip", package="smwrGraphs")
#' demo(topic="PiperScript", package="smwrGraphs")
#' }
#' @export setGraph
setGraph <- function(graphNum, layout, noTicks=NULL) {
	# Coding History:
	#    2008Jun27 DLLorenz Original coding.
	#    2010Nov30 DLLorenz Modified for R
	#    2011Oct24 DLLorenz Tweaks for package
	#    2014Jun26 DLLorenz Converted to roxygen.
	#
  par(fig=layout[[graphNum]]$fig)
  margin <- layout[[graphNum]]$margin
  ## this code protects against NAs
  if(!is.null(noTicks))
    margin[noTicks] <- ifelse(margin[noTicks] == 0, -101, -margin[noTicks])
  par(new=TRUE)
  invisible(margin)
}
USGS-R/smwrGraphs documentation built on Oct. 11, 2022, 6:11 a.m.