Produce a ggplot2 version of the default x-y
plot for an sma fit: the data points plus the fitted (standardised)
major axis line(s), with separate colours for each group where present. This
is a ggplot2-based alternative to the base-graphics plot.sma.
# S3 method for class 'sma'
ggplot(data = NULL, mapping = aes(), ..., environment = parent.frame())An object of class sma, as returned by sma
or ma. (Named data for consistency with the
ggplot2::ggplot generic.)
Present for consistency with the
ggplot2::ggplot generic; not used.
Further arguments passed to geom_line for
the fitted lines (for example linewidth or linetype).
A ggplot object.
Data and fitted lines are drawn on the natural (back-transformed)
scale of the original variables. Where the fit used a log transformation
(log was one of "x", "y" or "xy"), the
corresponding axis is drawn on a log10 scale via
scale_x_log10 / scale_y_log10.
The fitted line geometry mirrors the curve logic used by
plot.sma, so both plotting methods agree.
The returned object is a standard ggplot object and can be further
customised with additional layers, themes, scales and facets in the usual
way.
if (FALSE) { # \dontrun{
data(leaflife)
leaf.low.soilp <- subset(leaflife, soilp == "low")
# Single fit
ft1 <- sma(longev ~ lma, data = leaf.low.soilp, log = "xy")
ggplot2::ggplot(ft1)
# Grouped fit with common-slope test
ft2 <- sma(longev ~ lma * rain, data = leaf.low.soilp, log = "xy")
ggplot2::ggplot(ft2)
# ggplot object can be extended as usual
ggplot2::ggplot(ft2) + ggplot2::theme_minimal()
} # }