hdiffplot               package:hexbin               R Documentation

_P_l_o_t _o_f _D_o_m_a_i_n _a_n_d _M_e_d_i_a_n _D_i_f_f_e_r_e_n_c_e_s _o_f _T_w_o "_h_e_x_b_i_n" _O_b_j_e_c_t_s

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

     Let 'bin1' and 'bin2' represent two 'hexbin' objects with scaling,
     plot shapes, and bin sizes.  This plot distinguishes cells unique
     to 'bin1', cells in common, and cells unique to 'bin2' using
     color.  When the erode components are present, color also
     distinguishes the two erosion medians.  An arrow shows the vector
     from the median of 'bin1' to the median of 'bin2'.

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

     hdiffplot(bin1, bin2 = NULL, xbnds, ybnds,
               focus = if(is.null(bin2)) 1:length(bin1) else c(1, 2),
               col.control = list(medhex = "white", med.bord = "black",
               focus = NULL, focus.border = NULL, back.col = "grey"),
               arrows = TRUE, size = unit(0.1, "inches"), lwd = 2,
               eps = 1e-6, unzoom = 1.04, xlab = "", ylab = "",
               main = deparse(mycall), ...)

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

bin1, bin2: two objects of class 'hexbin'.

xbnds,ybnds: global x- and y-axis plotting limits.  Used primarily for
          multiple comparison plots.

   focus: ...........

col.control: ...........

  arrows: ...........

  border: border arguments to polygon

    size: arrow type size in inches.

     eps: distance criteria for distinct medians

  unzoom: plot limit expansion factor when xbnds is missing

     lwd: ...............

    xlab: ...............

    ylab: ...............

    main: main title for the plot; automatically constructed by
          default.

     ...: ...............

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

     The hexbin objects for comparison, 'bin1' and 'bin2', must have
     the same plotting limits and cell size.  The plot produces a
     comparison overlay of the cells in the two objects.  If external
     global scaling is not supplied, the algorithm determines plotting
     limits to increase resolution.  For example, the objects may be
     the result of the 'erode.hexbin()' and include only high count
     cells containing 50 of the counts.  The density, border, and pen
     arguments correspond to the polygon function calls for plotting
     six types of cells.  The cell types are respectively:

       unique cells of bin1,
       joint cells,
       unique cells of bin2,
       median cell of bin1,
       median cell of bin2,
       median cell if identical.

     The 'erode' components of the hexbin objects must be present for
     the medians to plot.  The algorithm select a single cell for the
     median if there are algorithmic ties.

     The 'pen' numbers for types of cells start at Pen 2.  Pen 1 is
     presumed black.  The suggested six additional colors are light
     blue, light gray, light red, blue, red, and black.  Carr (1991)
     shows an example for black and white printing.  That plot changes
     the six colors to light gray, dark gray, white, black, black, and
     black.  It changes the 4th, 5th, and 6th argument of border to
     TRUE.  It also changes 4th, 5th and 6th argument of density to 0. 
     In other words cells in common do not show and medians cells
     appear as outlines.

     When 'xbnds' is missing, the plot changes graphics parameters and
     resets them.  The function also zooms in based on the available
     data to provide increased resolution.

_R_e_f_e_r_e_n_c_e_s:

     see in 'grid.hexagons'.

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

     'hexbin', 'smooth.hexbin', 'erode.hexbin',  'hcell2xy', 
     'gplot.hexbin', 'hboxplot',  'grid.hexagons', 'grid.hexlegend'.

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

     ## Comparison of two bivariate boxplots
     x1 <- rnorm(10000)
     y1 <- rnorm(10000)
     x2 <- rnorm(10000,mean=.5)
     y2 <- rnorm(10000,mean=.5)
     xbnds <- range(x1,x2)
     ybnds <- range(y1,y2)

     bin1 <- hexbin(x1,y1,xbnds=xbnds,ybnds=ybnds)
     bin2 <- hexbin(x2,y2,xbnds=xbnds,ybnds=ybnds)
     erodebin1 <- erode.hexbin(smooth.hexbin(bin1))
     erodebin2 <- erode.hexbin(smooth.hexbin(bin2))

     hdiffplot(erodebin1,erodebin2)

     x3 <- rnorm(10000,mean=-1)
     y3 <- rnorm(10000,mean=-.5)
     xbnds <- range(x1,x2,x3)
     ybnds <- range(y1,y2,y3)

     bin1 <- hexbin(x1,y1,xbnds=xbnds,ybnds=ybnds)
     bin2 <- hexbin(x2,y2,xbnds=xbnds,ybnds=ybnds)
     bin3 <- hexbin(x3,y3,xbnds=xbnds,ybnds=ybnds)
     erodebin1 <- erode.hexbin(smooth.hexbin(bin1))
     erodebin2 <- erode.hexbin(smooth.hexbin(bin2))
     erodebin3 <- erode.hexbin(smooth.hexbin(bin3))

     bnlst <- list(b1=erodebin1, b2=erodebin2, b3=erodebin3)
     hdiffplot(bnlst)

