optShape               package:hexbin               R Documentation

_O_p_t_i_m_a_l _S_h_a_p_e _P_a_r_a_m_e_t_e_r _f_o_r _H_e_x_b_i_n _V_i_e_w_p_o_r_t

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

     Takes a viewport or a given height and width and returns the shape
     parameter that will fill the specified plotting region with the
     appropriately shaped hexagons.  If margins are specified the
     margins are subtracted from height and width before the shape
     parameter is specified.

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

     optShape(vp, height = NULL, width = NULL, mar = NULL)

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

      vp: a 'viewport' object, optional see details

  height: the height of the plotting region, can be numeric or units

   width: The width of the plotting region, can be numeric or units

     mar: A four element numeric or units vector describing the margins
          in the order 'c(bottom, left, top, right)'

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

     a scalar numeric value specifiyng 'shape'.

_W_a_r_n_i_n_g:

     If a viewport is given as an argument it should already be pushed
     on the graphics device or it will have null units and a
     meaningless shape parameter will be returned.

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

     Nicholas Lewin-Koh

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

     'hexViewport', 'hexVP-class', 'hexbin'

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

     x <- rgamma(10000,.9)
     m <- as.logical(rbinom(10000,1,.17))
     x[m] <- -x[m]
     y <- rnorm(x,abs(x))
     vp <- plotViewport(xscale= range(x)+c(-.5,.5),
                        yscale= range(y)+c(-.5,.5),
                  default.units = "native")
     grid.newpage()
     pushViewport(vp)
     grid.rect()
     shape <- optShape(vp)
     shape
     hb <- hexbin(x,y,xbins=40,shape=shape)
     grid.hexagons(hb,colramp=BTY)

