| draw.smooth_estimates | R Documentation | 
smooth_estimates()Plot the result of a call to smooth_estimates()
## S3 method for class 'smooth_estimates'
draw(
  object,
  constant = NULL,
  fun = NULL,
  contour = TRUE,
  grouped_by = FALSE,
  contour_col = "black",
  n_contour = NULL,
  ci_alpha = 0.2,
  ci_col = "black",
  smooth_col = "black",
  resid_col = "steelblue3",
  decrease_col = "#56B4E9",
  increase_col = "#E69F00",
  change_lwd = 1.75,
  partial_match = FALSE,
  discrete_colour = NULL,
  discrete_fill = NULL,
  continuous_colour = NULL,
  continuous_fill = NULL,
  angle = NULL,
  ylim = NULL,
  crs = NULL,
  default_crs = NULL,
  lims_method = "cross",
  caption = TRUE,
  ...
)
object | 
 a fitted GAM, the result of a call to   | 
constant | 
 numeric; a constant to add to the estimated values of the
smooth.   | 
fun | 
 function; a function that will be applied to the estimated values
and confidence interval before plotting. Can be a function or the name of a
function. Function   | 
contour | 
 logical; should contours be draw on the plot using
  | 
grouped_by | 
 logical; should factor by smooths be drawn as one panel
per level of the factor (  | 
contour_col | 
 colour specification for contour lines.  | 
n_contour | 
 numeric; the number of contour bins. Will result in
  | 
ci_alpha | 
 numeric; alpha transparency for confidence or simultaneous interval.  | 
ci_col | 
 colour specification for the confidence/credible intervals band. Affects the fill of the interval.  | 
smooth_col | 
 colour specification for the smooth line.  | 
resid_col | 
 colour specification for the partial residuals.  | 
decrease_col, increase_col | 
 colour specifications to use for
indicating periods of change.   | 
change_lwd | 
 numeric; the value to set the   | 
partial_match | 
 logical; should smooths be selected by partial matches
with   | 
discrete_colour | 
 a suitable colour scale to be used when plotting discrete variables.  | 
discrete_fill | 
 a suitable fill scale to be used when plotting discrete variables.  | 
continuous_colour | 
 a suitable colour scale to be used when plotting continuous variables.  | 
continuous_fill | 
 a suitable fill scale to be used when plotting continuous variables.  | 
angle | 
 numeric; the angle at which the x axis tick labels are to be
drawn passed to the   | 
ylim | 
 numeric; vector of y axis limits to use all all panels drawn.  | 
crs | 
 the coordinate reference system (CRS) to use for the plot. All
data will be projected into this CRS. See   | 
default_crs | 
 the coordinate reference system (CRS) to use for the
non-sf layers in the plot. If left at the default   | 
lims_method | 
 character; affects how the axis limits are determined. See
  | 
caption | 
 logical; show the smooth type in the caption of each plot?  | 
... | 
 additional arguments passed to   | 
load_mgcv()
# example data
df <- data_sim("eg1", seed = 21)
# fit GAM
m <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = df, method = "REML")
# plot all of the estimated smooths
sm <- smooth_estimates(m)
draw(sm)
# evaluate smooth of `x2`
sm <- smooth_estimates(m, select = "s(x2)")
# plot it
draw(sm)
# customising some plot elements
draw(sm, ci_col = "steelblue", smooth_col = "forestgreen", ci_alpha = 0.3)
# Add a constant to the plotted smooth
draw(sm, constant = coef(m)[1])
# Adding change indicators to smooths based on derivatives of the smooth
d <- derivatives(m, n = 100) # n to match smooth_estimates()
smooth_estimates(m) |>
  add_sizer(derivatives = d, type = "sizer") |>
  draw()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.