segplot             package:latticeExtra             R Documentation

_P_l_o_t _s_e_g_m_e_n_t_s _u_s_i_n_g _t_h_e _T_r_e_l_l_i_s _f_r_a_m_e_w_o_r_k

_D_e_s_c_r_i_p_t_i_o_n:

     This function can be used to systematically draw segments using a
     formula interface to produce Trellis displays using the lattice
     package.  Segments can be drawn either as lines or bars, and can
     be color coded by the value of a covariate, with a suitable
     legend.

_U_s_a_g_e:

     segplot(x, data, ...)

     ## S3 method for class 'formula':
     segplot(x, data,
             level = NULL, centers = NULL,
             prepanel = prepanel.segplot,
             panel = panel.segplot,
             xlab = NULL, ylab = NULL,
             horizontal = TRUE,
             ...,
             at, cuts = 30, colorkey = !is.null(level))

_A_r_g_u_m_e_n_t_s:

       x: Argument on which argument dispatch is carried out.  For the
          '"formula"' method, a formula of the form 'y ~ x1 + x2' (with
          further conditioning variables appended if necessary).  The
          terms in the formula must all be vectors of the same length. 
          Each element causes a line segment or rectangle to be drawn,
          with the vertical location determined by 'y' and horizontal
          endpoints determined by 'x1' and 'x2'.  

    data: An optional data frame, list or environment where variables
          in the formula, as well as 'level', will be evaluated. 

   level: An optional covariate that determines color coding of the
          segments

 centers: optional vector of 'centers' of the segments. If specified,
          points will be plotted at these 'y'-locations.  

prepanel: function determining range of the data rectangle from data to
          be used in a panel. 

   panel: function to render the graphic given the data.  This is the
          function that actually implements the display.  

xlab, ylab: Labels for the axes.  By default both are missing. 

horizontal: logical, whether the segments are to be drawn horizontally
          (the default) or vertically.  This essentially swaps the role
          of the x- and y-axes in each panel. 

     ...: further arguments.  Arguments to 'levelplot' as well as to
          the default panel function 'panel.segplot' can be supplied
          directly to 'segplot'. 

colorkey: logical indicating whether a legend showing association of
          segment colors to values of 'level' should be shown, or a
          list to control details of such a color key.  See details
          below. 

at, cuts: 'at' specifies the values of 'level' where the color code
          changes.  If 'at' is missing, it defaults to 'cuts'
          equispaced locations spanning the range of 'levels' 

_D_e_t_a_i_l_s:

     The 'levelplot' function from the lattice package is used to
     internally to implement this function.  In particular, the
     colorkey mechanism is used as it is, and documentation for
     'levelplot' should be consulted to learn how to fine tune it.

_V_a_l_u_e:

     An object of class '"trellis"'. The 'update' method can be used to
     update components of the object and the 'print' method (usually
     called by default) will plot it on an appropriate plotting device.

_N_o_t_e:

     Currently only horizontal segments are supported.  Vertical
     segments can be obtained by modifying the prepanel and panel
     functions suitably.

_A_u_t_h_o_r(_s):

     Deepayan Sarkar deepayan.sarkar@r-project.org

_S_e_e _A_l_s_o:

     'Lattice', 'levelplot', 'xyplot'

_E_x_a_m_p_l_e_s:

     segplot(factor(1:10) ~ rnorm(10) + rnorm(10), level = runif(10))

     data(USCancerRates)

     segplot(reorder(factor(county), rate.male) ~ LCL95.male + UCL95.male,
             data = subset(USCancerRates, state == "Washington"))

     segplot(reorder(factor(county), rate.male) ~ LCL95.male + UCL95.male,
             data = subset(USCancerRates, state == "Washington"),
             draw.bands = FALSE, centers = rate.male)

     segplot(reorder(factor(county), rate.male) ~ LCL95.male + UCL95.male,
             data = subset(USCancerRates, state == "Washington"),
             level = rate.female, col.regions = terrain.colors)

