grid_legend               package:vcd               R Documentation

_L_e_g_e_n_d _F_u_n_c_t_i_o_n _f_o_r _g_r_i_d _G_r_a_p_h_i_c_s

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

     This function can be used to add legends to _grid-based_ plots.

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

     grid_legend(x, y, pch, col, labels, frame = TRUE, hgap = unit(0.5, "lines"),
       vgap = unit(0.3, "lines"), default_units = "lines", gp = gpar(),
       draw = TRUE, title = "Legend:")

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

    x, y: coordinates of the legend

     pch: integer vector of plotting symbols

     col: character vector of colors for the symbols

  labels: character vector of labels corresponding to the symbols

   frame: logical indicating whether the legend should have a border or
          not.

    hgap: object of class '"unit"' specifying the space between symbols
          and labels

    vgap: object of class '"unit"' specifying the space between the
          lines

default_units: character string indicating the default unit

      gp: object of class '"gpar"' used for the legend

    draw: logical indicating whether the legend be drawn or not.

   title: character string indicating the plot's title

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

     Invisibly, the legend as a '"grob"' object.

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

     David Meyer David.Meyer@R-project.org

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

     'legend'

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

     data(Lifeboats)
     attach(Lifeboats)
     ternaryplot(Lifeboats[,4:6],
       pch = ifelse(side == "Port", 1, 19),
       col = ifelse(side == "Port", "red", "blue"),
       id  = ifelse(men / total > 0.1, as.character(boat), NA),
       prop_size = 2,
       dimnames_position = "edge",
       main = "Lifeboats on Titanic")
     grid_legend(0.8, 0.9, c(1, 19), c("red", "blue"),
       c("Port", "Starboard"), title = "SIDE")

