ggsmooth               package:ggplot               R Documentation

_G_r_o_b _f_u_n_c_t_i_o_n: _s_m_o_o_t_h

_D_e_s_c_r_i_p_t_i_o_n:

     Add a smooth line to a plot

_U_s_a_g_e:

     ggsmooth(plot = .PLOT, aesthetics=list(), ..., data=NULL)

_A_r_g_u_m_e_n_t_s:

    plot: the plot object to modify

aesthetics: named list of aesthetic mappings, see details for more
          information

     ...: other options, see details for more information

    data: data source, if not specified the plot default will be used

_D_e_t_a_i_l_s:

     This grob adds a smoother to the graphic to aid the eye in seeing
     important patterns, especially when there is a lot of
     overplotting.

     You can customise this very freely, firstly by choosing the
     function used to fit the smoother (eg. 'loess', 'lm', 'rlm',
     'gam', 'glm') and the formula used to related the y and x values
     (eg. 'y ~ x', 'y ~ poly(x,3)').

     This smoother is automatically restricted to the range of the
     data.  If you want to perform predictions (or fit more complicated
     variabels with covariates) then you should fit the model and plot
     the predicted results.

     Aesthetic mappings that this grob function understands:

        *  'x':x position (required)

        *  'y':y position (required)

        *  'size':size of the point, in mm (see 'scsize)'

        *  'colour':point colour (see 'sccolour)'

        *  'weight': observation weights

     These can be specified in the plot defaults (see 'ggplot') or in
     the 'aesthetics' argument.  If you want to modify the position of
     the points or any axis options, you will need to add a position
     scale to the plot.  These functions start with 'ps', eg.
     'pscontinuous' or 'pscategorical'

     Other options:

        *  'method':smoothing method (function) to use

        *  'formula':formula to use in smoothing function

        *  'se':display one standard error on either side of fit? (true
           by default)

        *  other arguments are passed to smoothing function

_A_u_t_h_o_r(_s):

     Hadley Wickham <h.wickham@gmail.com>

_E_x_a_m_p_l_e_s:

     p <- ggpoint(ggplot(mtcars, aesthetics=list(y=wt, x=qsec)))
     ggsmooth(p)
     ggsmooth(p, span=0.9)
     ggsmooth(p, method=lm)
     ggsmooth(p, method=lm, formula = y~splines::ns(x,3))
     ggsmooth(p, method=MASS::rlm, formula = y~splines::ns(x,3))

