R/fun_plot.R

Defines functions fun_plot

Documented in fun_plot

#' plot sin(x) and sin(x/2) functions
#'
#' calling curve() to plot these functions.
#'
#' @param from the starting point for x-axis
#' @param to  the ending point for x-axis
#' @param ... other parameters directly passed to curve()
#'
#' @return Null
#' @export
#'
#' @examples
#' fun_plot(-pi, pi)
#'
fun_plot <- function(from = -pi, to = pi, ...) {
  graphics::curve(sin, from = from, to = to, ylab="y",  ...)
  graphics::curve(sin(x / 2), from = from, to = to, add = T, col = "red")
  legend("topleft", legend = c("sin(x)", "sin(x/2)"), nc = 1, lty = "solid", col = c("black", "red"), bty = "n")
}
fortune9/RToyPackage documentation built on Aug. 15, 2020, 12:40 a.m.