xy.coords             package:grDevices             R Documentation

_E_x_t_r_a_c_t_i_n_g _P_l_o_t_t_i_n_g _S_t_r_u_c_t_u_r_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     'xy.coords' is used by many functions to obtain x and y
     coordinates for plotting. The use of this common mechanism across
     all R functions produces a measure of consistency.

_U_s_a_g_e:

     xy.coords(x, y = NULL, xlab = NULL, ylab = NULL, log = NULL,
               recycle = FALSE)

_A_r_g_u_m_e_n_t_s:

    x, y: the x and y coordinates of a set of points. Alternatively, a
          single argument 'x' can be provided.

xlab,ylab: names for the x and y variables to be extracted.

     log: character, '"x"', '"y"' or both, as for 'plot'.  Sets
          negative values to 'NA' and gives a warning.

 recycle: logical; if 'TRUE', recycle ('rep') the shorter of 'x' or 'y'
          if their lengths differ.

_D_e_t_a_i_l_s:

     An attempt is made to interpret the arguments 'x' and 'y' in a way
     suitable for plotting.

     If 'y' is 'NULL' and 'x' is a

     _f_o_r_m_u_l_a: of the form 'yvar ~ xvar'. 'xvar' and 'yvar' are used as
          x and y variables.

     _l_i_s_t: containing components 'x' and 'y', these are used to define
          plotting coordinates.

     _t_i_m_e _s_e_r_i_e_s: the x values are taken to be 'time(x)' and the y
          values to be the time series.

     _m_a_t_r_i_x _w_i_t_h _t_w_o _c_o_l_u_m_n_s: the first is assumed to contain the x
          values and the second the y values.

     In any other case, the 'x' argument is coerced to a vector and
     returned as *y* component where the resulting 'x' is just the
     index vector '1:n'.  In this case, the resulting 'xlab' component
     is set to '"Index"'.

     If 'x' (after transformation as above) inherits from class
     '"POSIXt"' it is coerced to class '"POSIXct"'.

_V_a_l_u_e:

     A list with the components 

       x: numeric (i.e., '"double"') vector of abscissa values.

       y: numeric vector of the same length as 'x'.

    xlab: 'character(1)' or 'NULL', the 'label' of 'x'.

    ylab: 'character(1)' or 'NULL', the 'label' of 'y'.

_S_e_e _A_l_s_o:

     'plot.default', 'lines', 'points' and 'lowess' are examples of
     functions which use this mechanism.

_E_x_a_m_p_l_e_s:

     xy.coords(stats::fft(c(1:10)), NULL)

     with(cars, xy.coords(dist ~ speed, NULL)$xlab ) # = "speed"

     xy.coords(1:3, 1:2, recycle=TRUE)
     xy.coords(-2:10,NULL, log="y")
     ##> warning: 3 y values <=0 omitted ..

