grid.arrows               package:grid               R Documentation

_D_r_a_w _A_r_r_o_w_s

_D_e_s_c_r_i_p_t_i_o_n:

     This will draw arrows at either end of a line or an existing
     line.to, lines, or segments grob.

_U_s_a_g_e:

     grid.arrows(x = c(0.25, 0.75), y = 0.5, default.units = "npc",
                 grob = NULL,
                 angle = 30, length = unit(0.25, "inches"),
                 ends = "last", type = "open",
                 gp = gpar(), draw = TRUE, vp = NULL)

_A_r_g_u_m_e_n_t_s:

       x: A numeric vector or unit object specifying x-values.

       y: A numeric vector or unit object specifying y-values.

default.units: A string indicating the default units to use if 'x' or
          'y' are only given as numeric vectors.

    grob: A grob to add arrows to;  currently can only be a line.to,
          lines, or segments grob. 

   angle: A numeric specifying (half) the width of the arrow head (in
          degrees). 

  length: A unit object specifying the length of the arrow head. 

    ends: One of '"first"', '"last"', or '"both"', indicating which end
          of the line to add arrow heads. 

    type: Either '"open"' or '"closed"' to indicate the type of arrow
          head.   

      gp: An object of class 'gpar', typically the output from a call
          to the function 'gpar'.  This is basically a list of
          graphical parameter settings.

    draw: A logical value indicating whether graphics output should be
          produced.

      vp: A Grid viewport object (or NULL).

_D_e_t_a_i_l_s:

     If the grob argument is specified, this overrides any x and/or y
     arguments.

_V_a_l_u_e:

     An object of class '"grob"'.

_A_u_t_h_o_r(_s):

     Paul Murrell

_S_e_e _A_l_s_o:

     Grid, 'viewport', 'grid.line.to', 'grid.lines', 'grid.segments'

_E_x_a_m_p_l_e_s:

     push.viewport(viewport(layout=grid.layout(2, 4)))
     push.viewport(viewport(layout.pos.col=1,
                            layout.pos.row=1))
     grid.rect(gp=gpar(col="grey"))
     grid.arrows()
     pop.viewport()
     push.viewport(viewport(layout.pos.col=2,
                            layout.pos.row=1))
     grid.rect(gp=gpar(col="grey"))
     grid.arrows(angle=15, type="closed")
     pop.viewport()
     push.viewport(viewport(layout.pos.col=3,
                            layout.pos.row=1))
     grid.rect(gp=gpar(col="grey"))
     grid.arrows(angle=5, length=unit(0.1, "npc"),
                 type="closed", gp=gpar(fill="white"))
     pop.viewport()
     push.viewport(viewport(layout.pos.col=4,
                            layout.pos.row=1))
     grid.rect(gp=gpar(col="grey"))
     grid.arrows(x=unit(0:80/100, "npc"),
                 y=unit(1 - (0:80/100)^2, "npc"))
     pop.viewport()
     push.viewport(viewport(layout.pos.col=1,
                            layout.pos.row=2))
     grid.rect(gp=gpar(col="grey"))
     grid.arrows(ends="both")
     pop.viewport()
     push.viewport(viewport(layout.pos.col=2,
                            layout.pos.row=2))
     grid.rect(gp=gpar(col="grey"))
     # Recycling arguments
     grid.arrows(x=unit(1:10/11, "npc"), y=unit(1:3/4, "npc"))
     pop.viewport()
     push.viewport(viewport(layout.pos.col=3,
                            layout.pos.row=2))
     grid.rect(gp=gpar(col="grey"))
     gs <- grid.segments(x0=unit(1:4/5, "npc"),
                         x1=unit(1:4/5, "npc"))
     grid.arrows(grob=gs, length=unit(0.1, "npc"),
                 type="closed", gp=gpar(fill="white"))
     pop.viewport()
     push.viewport(viewport(layout.pos.col=4,
                            layout.pos.row=2))
     grid.rect(gp=gpar(col="grey"))
     gl <- grid.lines(x=unit(0:80/100, "npc"),
                      y=unit((0:80/100)^2, "npc"))
     grid.arrows(grob=gl, angle=15, type="closed", gp=gpar(fill="black"))
     pop.viewport()
     push.viewport(viewport(layout.pos.col=1,
                            layout.pos.row=2))
     grid.move.to(x=0.5, y=0.8)
     pop.viewport()
     push.viewport(viewport(layout.pos.col=4,
                            layout.pos.row=1))
     glt <- grid.line.to(x=0.5, y=0.2, gp=gpar(lwd=3))
     grid.arrows(grob=glt, ends="first", gp=gpar(lwd=3))
     pop.viewport(2)
     grid.edit(gl, y=unit((0:80/100)^3, "npc"))

