hexViewport              package:hexbin              R Documentation

_C_o_m_p_u_t_e _a _G_r_i_d _V_i_e_w_p_o_r_t _f_o_r _H_e_x_a_g_o_n / _H_e_x_b_i_n _G_r_a_p_h_i_c_s

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

     Builds a 'grid' viewport for hexagon or 'hexbin' graphics.  This
     builds on the concepts of the 'grid' package, see 'viewport'.

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

     hexViewport(x, offset = unit(0,"inches"), mar = NULL,
                 xbnds = NULL, ybnds = NULL, newpage = FALSE,
                 clip = "off", vp.name = NULL)

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

       x: a 'hexbin' object.

  offset: a 'unit' object.

     mar: margins as 'unit's, of length 4 or 1.

xbnds, ybnds: bounds for x- and y- plotting range; these default to the
          corresponding slots of 'x'.

 newpage: logical indicating if a new graphics page should be openend,
          i.e., 'grid.newpage()'.

    clip: simply passed to 'viewport()'.

 vp.name: name of viewport; defaults to random name.

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

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

     an S4 object of class '"hexVP"', see hexVP-class for more, with
     its main slot 'hexVp' a 'viewport' for grid graphics.

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

     'viewport' and the main _"handlers"_ 'pushHexport' and
     'popViewport'; further 'gplot.hexbin' and 'hboxplot' which build
     on 'hexViewport'.

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

     set.seed(131)
     x <- rnorm(7777)
     y <- rt   (7777, df=3)

     ## lower resolution binning and overplotting with counts
     bin <- hexbin(x,y,xbins=25)
     P <- plot(bin)
     xy <- hcell2xy(bin)
     pushHexport(P$plot.vp)
     i <- bin@count <= 3
     grid.text(as.character(bin@count[i]), xy$x[i], xy$y[i],
               default.units = "native")
     grid.points(x[1:20],y[1:20]) # to show some points rather than counts
     popViewport()

