Skip to contents

Uses Grid graphics to draw a metroglyph (Anderson 1957; duToit et al. 1986) .

Usage

metroglyphGrob(
  x = 0.5,
  y = 0.5,
  z,
  size = 1,
  circle.size = 5,
  col.circle = "black",
  col.ray = "black",
  col.points = "black",
  fill = NA,
  lwd.circle = 1,
  lwd.ray = 1,
  alpha = 1,
  angle.start = 0,
  angle.stop = 2 * base::pi,
  lineend = c("round", "butt", "square"),
  grid.levels = NULL,
  draw.grid = FALSE,
  grid.point.size = 10
)

Arguments

x

A numeric vector or unit object specifying x-locations.

y

A numeric vector or unit object specifying y-locations.

z

A numeric vector specifying the length of rays.

size

The size of rays.

circle.size

The size of the central circle (radius).

col.circle

The circle colour.

col.ray

The colour of rays.

col.points

The colour of grid points.

fill

The circle fill colour.

lwd.circle

The circle line width.

lwd.ray

The ray line width.

alpha

The alpha transparency value.

angle.start

The start angle for the glyph rays in radians. Default is zero.

angle.stop

The stop angle for the glyph rays in radians. Default is \(2\pi\).

lineend

The line end style for the rays. Either "round", "butt" or "square".

grid.levels

A list of grid levels (as vectors) corresponding to the values in z at which points are to be plotted. The values in z should be present in the list specified.

draw.grid

logical. If TRUE, grid points are plotted along the whiskers. Default is FALSE.

grid.point.size

The size of the grid points in native units.

Value

A gTree object.

References

Anderson E (1957). “A semigraphical method for the analysis of complex problems.” Proceedings of the National Academy of Sciences of the United States of America, 43(10), 923.

duToit SHC, Steyn AGW, Stumpf RH (1986). Graphical Exploratory Data Analysis, Springer Texts in Statistics. Springer-Verlag, New York. ISBN 978-1-4612-9371-2.

Examples

mglyph1 <- metroglyphGrob(x = 300, y = 200,
                          z = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33),
                          size = 25, circle.size = 2)

mglyph2 <- metroglyphGrob(x = 800, y = 200,
                          z = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33),
                          size = 25, circle.size = 5)

mglyph3 <- metroglyphGrob(x = 300, y = 600,
                          z = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33),
                          size = 25, circle.size = 0,
                          angle.start = base::pi, angle.stop = -base::pi)

mglyph4 <- metroglyphGrob(x = 800, y = 600,
                          z = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33),
                          size = 25, circle.size = 10,
                          angle.start = base::pi, angle.stop = -base::pi)

grid::grid.newpage()
grid::grid.draw(mglyph1)
grid::grid.draw(mglyph2)
grid::grid.draw(mglyph3)
grid::grid.draw(mglyph4)


mglyph1 <- metroglyphGrob(x = 200, y = 100,
                          z = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33),
                          size = 25, circle.size = 2,
                          angle.start = -base::pi, angle.stop = 0)

mglyph2 <- metroglyphGrob(x = 800, y = 100,
                          z = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33),
                          size = 25, circle.size = 5,
                          angle.start = -base::pi, angle.stop = 0)

mglyph3 <- metroglyphGrob(x = 200, y = 700,
                          z = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33),
                          size = 25, circle.size = 0,
                          angle.start = 0, angle.stop = base::pi)

mglyph4 <- metroglyphGrob(x = 800, y = 700,
                          z = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33),
                          size = 25, circle.size = 10,
                          angle.start = 0, angle.stop = base::pi)

grid::grid.newpage()
grid::grid.draw(mglyph1)
grid::grid.draw(mglyph2)
grid::grid.draw(mglyph3)
grid::grid.draw(mglyph4)


mglyph1 <- metroglyphGrob(x = 300, y = 200,
                          z = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33),
                          size = 25, circle.size = 2, lwd.circle = 3)

mglyph2 <- metroglyphGrob(x = 900, y = 200,
                          z = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33),
                          size = 25, circle.size = 5, lwd.circle = 3)

mglyph3 <- metroglyphGrob(x = 300, y = 600,
                          z = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33),
                          size = 25, circle.size = 0,
                          angle.start = base::pi, angle.stop = -base::pi,
                          lwd.ray = 3)

mglyph4 <- metroglyphGrob(x = 900, y = 600,
                          z = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33),
                          size = 25, circle.size = 10,
                          angle.start = base::pi, angle.stop = -base::pi,
                          lwd.ray = 3)

grid::grid.newpage()
grid::grid.draw(mglyph1)
grid::grid.draw(mglyph2)
grid::grid.draw(mglyph3)
grid::grid.draw(mglyph4)


mglyph1 <- metroglyphGrob(x = 300, y = 200,
                          z = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33),
                          size = 25, circle.size = 2, lwd.circle = 3,
                          col.ray = RColorBrewer::brewer.pal(6, "Dark2"),
                          col.circle = "gray")

mglyph2 <- metroglyphGrob(x = 900, y = 200,
                          z = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33),
                          size = 25, circle.size = 5, lwd.circle = 3,
                          col.ray = RColorBrewer::brewer.pal(6, "Dark2"),
                          col.circle = "white", fill = "black")

mglyph3 <- metroglyphGrob(x = 300, y = 600,
                          z = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33),
                          size = 25, circle.size = 0,
                          angle.start = base::pi, angle.stop = -base::pi,
                          lwd.ray = 3,
                          col.ray = RColorBrewer::brewer.pal(6, "Dark2"))

mglyph4 <- metroglyphGrob(x = 900, y = 600,
                          z = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33),
                          size = 25, circle.size = 10,
                          angle.start = base::pi, angle.stop = -base::pi,
                          lwd.ray = 5, lwd.circle = 15,
                          col.ray = RColorBrewer::brewer.pal(6, "Dark2"),
                          col.circle = "white", fill = "gray")

grid::grid.newpage()
grid::grid.draw(mglyph1)
grid::grid.draw(mglyph2)
grid::grid.draw(mglyph3)
grid::grid.draw(mglyph4)


mg1 <- metroglyphGrob(x = 300, y = 200,
                      z = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33),
                      size = 15, circle.size = 5,
                      lwd.ray = 5)

mg2 <- metroglyphGrob(x = 500, y = 400,
                      z = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33),
                      size = 15, circle.size = 5,
                      lwd.ray = 5, lineend = "butt")

mg3 <- metroglyphGrob(x = 700, y = 600,
                      z = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33),
                      size = 15, circle.size = 5,
                      lwd.ray = 5, lineend = "square")

grid::grid.newpage()
grid::grid.draw(mg1)
grid::grid.draw(mg2)
grid::grid.draw(mg3)


gl <- split(x = rep(c(1, 2, 3), 6),
            f = rep(1:6, each = 3))

mglyph1 <- metroglyphGrob(x = 200, y = 200,
                          z = c(1, 3, 2, 1, 2, 3),
                          size = 6, circle.size = 2, lwd.circle = 3,
                          draw.grid = TRUE, grid.levels = gl)

mglyph2 <- metroglyphGrob(x = 800, y = 200,
                          z = c(1, 3, 2, 1, 2, 3),
                          size = 6, circle.size = 5, lwd.circle = 3,
                          draw.grid = TRUE, grid.levels = gl)

mglyph3 <- metroglyphGrob(x = 250, y = 600,
                          z = c(1, 3, 2, 1, 2, 3),
                          size = 6, circle.size = 0,
                          angle.start = base::pi, angle.stop = -base::pi,
                          lwd.ray = 3,
                          draw.grid = TRUE, grid.levels = gl)

mglyph4 <- metroglyphGrob(x = 850, y = 600,
                          z = c(1, 3, 2, 1, 2, 3),
                          size = 6, circle.size = 10,
                          angle.start = base::pi, angle.stop = -base::pi,
                          lwd.ray = 3,
                          draw.grid = TRUE, grid.levels = gl)

grid::grid.newpage()
grid::grid.draw(mglyph1)
grid::grid.draw(mglyph2)
grid::grid.draw(mglyph3)
grid::grid.draw(mglyph4)


gl <- split(x = rep(c(0, 1, 2), 6),
            f = rep(1:6, each = 3))

mglyph1 <- metroglyphGrob(x = 200, y = 200,
                          z = c(0, 2, 1, 0, 1, 2),
                          size = 10, circle.size = 2, lwd.circle = 3,
                          draw.grid = TRUE, grid.levels = gl,
                          col.ray = RColorBrewer::brewer.pal(6, "Dark2"),
                          col.points = NA)

mglyph2 <- metroglyphGrob(x = 800, y = 200,
                          z = c(0, 2, 1, 0, 1, 2),
                          size = 10, circle.size = 5, lwd.circle = 3,
                          draw.grid = TRUE, grid.levels = gl,
                          col.ray = RColorBrewer::brewer.pal(6, "Dark2"))

mglyph3 <- metroglyphGrob(x = 250, y = 600,
                          z = c(0, 2, 1, 0, 1, 2),
                          size = 10, circle.size = 0,
                          angle.start = base::pi, angle.stop = -base::pi,
                          lwd.ray = 3,
                          draw.grid = TRUE, grid.levels = gl,
                          col.ray = RColorBrewer::brewer.pal(6, "Dark2"),
                          col.points = "white")

mglyph4 <- metroglyphGrob(x = 850, y = 600,
                          z = c(0, 2, 1, 0, 1, 2),
                          size = 10, circle.size = 10,
                          angle.start = base::pi, angle.stop = -base::pi,
                          lwd.ray = 3,
                          draw.grid = TRUE, grid.levels = gl,
                          col.ray = RColorBrewer::brewer.pal(6, "Dark2"),
                          col.points = NA, grid.point.size = 20)

grid::grid.newpage()
grid::grid.draw(mglyph1)
grid::grid.draw(mglyph2)
grid::grid.draw(mglyph3)
grid::grid.draw(mglyph4)