umxPlotFun: Easily plot functions in R

umxPlotFunR Documentation

Easily plot functions in R

Description

A wrapper for ggplot2::stat_function() that handles single or multiple functions.

Usage

umxPlotFun(
  fun = c("sin(x)", "cos(x)"),
  min = -1,
  max = 5,
  xlab = NULL,
  ylab = NULL,
  title = NULL,
  logY = c("no", "log", "log10"),
  logX = c("no", "log", "log10"),
  p = NULL
)

Arguments

fun

Function(s) to plot. Takes strings like c("3 + sin(x)^2", "cos(x)") or function objects.

min

x-range min.

max

x-range max.

xlab

Optional x axis label.

ylab

Optional y axis label.

title

Optional title for the plot.

logY

Set to "log" or "log10" to transform y coordinate.

logX

Set to "log" or "log10" to transform x coordinate.

p

Optional plot onto which to draw the function(s).

Details

Easily plot functions—like sin or x^2—using ggplot. Accepts bare functions, strings, or lists of strings/functions. Automatically generates a legend when multiple functions are provided.

Value

A ggplot graph object

See Also

ggplot2::stat_function()

Other Plotting functions: ggAddR(), plot.MxLISRELModel(), plot.MxModel(), plot.MxModelTwinMaker(), umx, umxPlot(), umxPlotACE(), umxPlotACEcov(), umxPlotACEv(), umxPlotCP(), umxPlotDoC(), umxPlotGxE(), umxPlotGxEbiv(), umxPlotIP(), umxPlotPredict(), umxPlotSexLim(), umxPlotSimplex()

Examples

## Not run: 
# Plotting multiple strings
p = umxPlotFun(c("sin(x)", "cos(x)"), max = 2*pi)

# Providing a named list to control legend labels
umxPlotFun(list(Sine = sin, Cosine = cos), max = 2*pi)

## End(Not run)


umx documentation built on May 18, 2026, 5:07 p.m.