convertNative              package:grid              R Documentation

_C_o_n_v_e_r_t _a _U_n_i_t _O_b_j_e_c_t _t_o _N_a_t_i_v_e _u_n_i_t_s

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

     *This function is deprecated in grid version 0.8 and will be made
     defunct in grid version 1.9*

     You should use the 'convertUnit()' function or one of its close
     allies instead.

     This function returns a numeric vector containing the specified x
     or y locations or dimensions, converted to "user" or "data" units,
     relative to the current viewport.

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

     convertNative(unit, dimension="x", type="location")

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

    unit: A unit object. 

dimension: Either "x" or "y". 

    type: Either "location" or "dimension". 

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

     A numeric vector.

_W_A_R_N_I_N_G:

     If you draw objects based on output from these conversion
     functions, then resize your device, the objects will be drawn 
     incorrectly - the base R display list will not recalculate these
     conversions.  This means that you can only rely on the results of 
     these calculations if the size of your device is fixed.

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

     Paul Murrell

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

     'grid.convert', 'unit'

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

     grid.newpage()
     pushViewport(viewport(width=unit(.5, "npc"),
                            height=unit(.5, "npc")))
     grid.rect()
     w <- convertNative(unit(1, "inches"))
     h <- convertNative(unit(1, "inches"), "y")
     # This rectangle starts off life as 1in square, but if you
     # resize the device it will no longer be 1in square
     grid.rect(width=unit(w, "native"), height=unit(h, "native"),
               gp=gpar(col="red"))
     popViewport(1)

     # How to use grid.convert(), etc instead
     convertNative(unit(1, "inches")) ==
       convertX(unit(1, "inches"), "native", valueOnly=TRUE)
     convertNative(unit(1, "inches"), "y", "dimension") ==
       convertHeight(unit(1, "inches"), "native", valueOnly=TRUE)

