R/plot_add.R

Defines functions plot_add

Documented in plot_add

#' plot_add adds a plot to a previous one
#' @title Add a plot to a previous one
#' @author Marc Girondot \email{marc.girondot@@gmail.com}
#' @return Nothing
#' @param ... Parameters for plot()
#' @family plot and barplot functions
#' @description To plot data, just add use it as a normal plot. It will plot 
#' the new data without axes, or labels for axes.\cr
#' This function is complementary to matlines() and matpoints() from package graphics.
#' @examples
#' \dontrun{
#' plot(x=1:100, y=sin(1:100), type="l", bty="n", xlim=c(1,200), xlab="x", ylab="y")
#' plot_add(x=1:200, y=cos(1:200), type="l", bty="n", col="red")
#' }
#' @export


plot_add <- function(...) 
  {
  	par(new=TRUE)
	par.plot <- list(...)

	par.plot <- modifyList(par.plot, list(xlab="", ylab="", main="", axes=FALSE, 
	xlim= ScalePreviousPlot()$xlim[1:2], ylim=ScalePreviousPlot()$ylim[1:2]))
	do.call(plot, par.plot) 
  }

Try the HelpersMG package in your browser

Any scripts or data that you put into this service are public.

HelpersMG documentation built on Sept. 12, 2024, 9:35 a.m.