Uses Grid
graphics to draw a profile glyph
(Chambers et al. 1983; duToit et al. 1986)
.
Usage
profileglyphGrob(
x = 0.5,
y = 0.5,
z,
size = 1,
col.bar = "black",
col.line = "black",
fill = NA,
lwd.bar = 1,
lwd.line = 1,
alpha = 1,
width = 5,
flip.axes = FALSE,
bar = TRUE,
line = TRUE,
mirror = TRUE,
linejoin = c("mitre", "round", "bevel"),
lineend = c("round", "butt", "square"),
grid.levels = NULL,
draw.grid = FALSE,
col.grid = "grey",
lwd.grid = 1
)
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 values to be plotted as dimensions of the profile (length of the bars).
- size
The size of glyphs.
- col.bar
The colour of bars.
- col.line
The colour of profile line(s).
- fill
The fill colour.
- lwd.bar
The line width of the bars.
- lwd.line
The line width of the profile line(s)
- alpha
The alpha transparency value.
- width
The width of the bars.
- flip.axes
logical. If
TRUE
, axes are flipped.- bar
logical. If
TRUE
, profile bars are plotted.- line
logical. If
TRUE
, profile line is plotted.- mirror
logical. If
TRUE
, mirror profile is plotted.- linejoin
The line join style for the profile line(s) and bars. Either
"mitre"
,"round"
or"bevel"
.- lineend
The line end style for the whisker lines. Either
"round"
,"butt"
or"square"
.- grid.levels
A list of grid levels (as vectors) corresponding to the values in
z
at which grid lines are to be plotted. The values inz
should be present in the list specified.- draw.grid
logical. If
TRUE
, grid lines are plotted along the bars. Default isFALSE
.- col.grid
The colour of the grid lines.
- lwd.grid
The line width of the grid lines.
Value
A gTree
object.
References
Chambers JM, Cleveland WS, Kleiner B, Tukey PA (1983).
Graphical Methods for Data Analysis.
Chapman and Hall/CRC, Boca Raton.
ISBN 978-1-351-07230-4.
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.
See also
Other grobs:
dotglyphGrob()
,
metroglyphGrob()
,
pieglyphGrob()
,
starglyphGrob()
,
tileglyphGrob()
Examples
# mirror = TRUE
dims = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33)
barglyph <- profileglyphGrob(x = 200, y = 200, z = dims,
size = 20)
barprofileglyph <- profileglyphGrob(x = 450, y = 200, z = dims,
size = 20, line = FALSE)
profileglyph <- profileglyphGrob(x = 700, y = 200, z = dims,
size = 20, line = TRUE, bar = FALSE)
grid::grid.newpage()
grid::grid.draw(barglyph)
grid::grid.draw(barprofileglyph)
grid::grid.draw(profileglyph)
barglyph <- profileglyphGrob(x = 200, y = 450, z = dims,
size = 20,
col.bar = "salmon", col.line = "salmon")
barprofileglyph <- profileglyphGrob(x = 450, y = 450, z = dims,
size = 20, line = FALSE,
col.bar = "cyan")
profileglyph <- profileglyphGrob(x = 700, y = 450, z = dims,
size = 20, line = TRUE, bar = FALSE,
col.line = "green")
grid::grid.draw(barglyph)
grid::grid.draw(barprofileglyph)
grid::grid.draw(profileglyph)
barglyph <- profileglyphGrob(x = 200, y = 700, z = dims, size = 20,
fill = "salmon")
barprofileglyph <- profileglyphGrob(x = 450, y = 700, z = dims,
size = 20, line = FALSE,
fill = "cyan")
profileglyph <- profileglyphGrob(x = 700, y = 700, z = dims, size = 20,
line = TRUE, bar = FALSE,
fill = "green")
grid::grid.draw(barglyph)
grid::grid.draw(barprofileglyph)
grid::grid.draw(profileglyph)
# mirror = FALSE
dims = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33)
barglyph <- profileglyphGrob(x = 200, y = 300, z = dims,
size = 20,
mirror = FALSE)
barprofileglyph <- profileglyphGrob(x = 450, y = 300, z = dims,
size = 20, line = FALSE,
mirror = FALSE)
profileglyph <- profileglyphGrob(x = 700, y = 300, z = dims,
size = 20, line = TRUE, bar = FALSE,
mirror = FALSE)
grid::grid.newpage()
grid::grid.draw(barglyph)
grid::grid.draw(barprofileglyph)
grid::grid.draw(profileglyph)
barglyph <- profileglyphGrob(x = 200, y = 550, z = dims,
size = 20, mirror = FALSE,
col.bar = "salmon", col.line = "salmon")
barprofileglyph <- profileglyphGrob(x = 450, y = 550, z = dims,
size = 20, line = FALSE, mirror = FALSE,
col.bar = "cyan")
profileglyph <- profileglyphGrob(x = 700, y = 550, z = dims,
size = 20, line = TRUE, bar = FALSE,
mirror = FALSE, col.line = "green")
grid::grid.draw(barglyph)
grid::grid.draw(barprofileglyph)
grid::grid.draw(profileglyph)#'
barglyph <- profileglyphGrob(x = 200, y = 800, z = dims, size = 20,
fill = "salmon", mirror = FALSE)
barprofileglyph <- profileglyphGrob(x = 450, y = 800, z = dims,
size = 20, line = FALSE, mirror = FALSE,
fill = "cyan")
profileglyph <- profileglyphGrob(x = 700, y = 800, z = dims, size = 20,
line = TRUE, bar = FALSE,
mirror = FALSE, fill = "green")
grid::grid.draw(barglyph)
grid::grid.draw(barprofileglyph)
grid::grid.draw(profileglyph)
# mirror = TRUE, flip.axes = TRUE
dims = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33)
barglyph <- profileglyphGrob(x = 200, y = 200, z = dims,
size = 20, flip.axes = TRUE)
barprofileglyph <- profileglyphGrob(x = 450, y = 200, z = dims,
size = 20, line = FALSE,
flip.axes = TRUE)
profileglyph <- profileglyphGrob(x = 700, y = 200, z = dims,
size = 20, line = TRUE, bar = FALSE,
flip.axes = TRUE)
grid::grid.newpage()
grid::grid.draw(barglyph)
grid::grid.draw(barprofileglyph)
grid::grid.draw(profileglyph)
barglyph <- profileglyphGrob(x = 200, y = 450, z = dims,
size = 20, flip.axes = TRUE,
col.bar = "salmon", col.line = "salmon")
barprofileglyph <- profileglyphGrob(x = 450, y = 450, z = dims,
size = 20, line = FALSE,
flip.axes = TRUE,
col.bar = "cyan")
profileglyph <- profileglyphGrob(x = 700, y = 450, z = dims,
size = 20, line = TRUE, bar = FALSE,
flip.axes = TRUE,
col.line = "green")
grid::grid.draw(barglyph)
grid::grid.draw(barprofileglyph)
grid::grid.draw(profileglyph)
barglyph <- profileglyphGrob(x = 200, y = 700, z = dims, size = 20,
flip.axes = TRUE,
fill = "salmon")
barprofileglyph <- profileglyphGrob(x = 450, y = 700, z = dims,
size = 20, line = FALSE,
flip.axes = TRUE,
fill = "cyan")
profileglyph <- profileglyphGrob(x = 700, y = 700, z = dims, size = 20,
line = TRUE, bar = FALSE,
flip.axes = TRUE,
fill = "green")
grid::grid.draw(barglyph)
grid::grid.draw(barprofileglyph)
grid::grid.draw(profileglyph)
# mirror = FALSE, flip.axes = TRUE
dims = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33)
barglyph <- profileglyphGrob(x = 200, y = 200, z = dims,
size = 20, flip.axes = TRUE,
mirror = FALSE)
barprofileglyph <- profileglyphGrob(x = 450, y = 200, z = dims,
size = 20, line = FALSE,
flip.axes = TRUE,
mirror = FALSE)
profileglyph <- profileglyphGrob(x = 700, y = 200, z = dims,
size = 20, line = TRUE, bar = FALSE,
flip.axes = TRUE,
mirror = FALSE)
grid::grid.newpage()
grid::grid.draw(barglyph)
grid::grid.draw(barprofileglyph)
grid::grid.draw(profileglyph)
barglyph <- profileglyphGrob(x = 200, y = 450, z = dims,
size = 20, mirror = FALSE,
flip.axes = TRUE,
col.bar = "salmon", col.line = "salmon")
barprofileglyph <- profileglyphGrob(x = 450, y = 450, z = dims,
size = 20, line = FALSE, mirror = FALSE,
flip.axes = TRUE,
col.bar = "cyan")
profileglyph <- profileglyphGrob(x = 700, y = 450, z = dims,
size = 20, line = TRUE, bar = FALSE,
flip.axes = TRUE,
mirror = FALSE, col.line = "green")
grid::grid.draw(barglyph)
grid::grid.draw(barprofileglyph)
grid::grid.draw(profileglyph)
barglyph <- profileglyphGrob(x = 200, y = 700, z = dims, size = 20,
flip.axes = TRUE,
fill = "salmon", mirror = FALSE)
barprofileglyph <- profileglyphGrob(x = 450, y = 700, z = dims,
size = 20, line = FALSE, mirror = FALSE,
flip.axes = TRUE,
fill = "cyan")
profileglyph <- profileglyphGrob(x = 700, y = 700, z = dims, size = 20,
line = TRUE, bar = FALSE,
flip.axes = TRUE,
mirror = FALSE, fill = "green")
grid::grid.draw(barglyph)
grid::grid.draw(barprofileglyph)
grid::grid.draw(profileglyph)
# linejoin variants
dims = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33)
pg1 <- profileglyphGrob(x = 200, y = 150, z = dims,
size = 25, lwd.bar = 5, width = 8)
pg2 <- profileglyphGrob(x = 500, y = 400, z = dims,
size = 25, lwd.bar = 5, width = 8,
linejoin = "round")
pg3 <- profileglyphGrob(x = 800, y = 650, z = dims,
size = 25, lwd.bar = 5, width = 8,
linejoin = "bevel")
grid::grid.newpage()
grid::grid.draw(pg1)
grid::grid.draw(pg2)
grid::grid.draw(pg3)
dims = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33)
pg1 <- profileglyphGrob(x = 200, y = 150, z = dims,
size = 25, lwd.line = 5, width = 8,
bar = FALSE)
pg2 <- profileglyphGrob(x = 500, y = 400, z = dims,
size = 25, lwd.line = 5, width = 8,
linejoin = "round", bar = FALSE)
pg3 <- profileglyphGrob(x = 800, y = 650, z = dims,
size = 25, lwd.line = 5, width = 8,
linejoin = "bevel", bar = FALSE)
grid::grid.newpage()
grid::grid.draw(pg1)
grid::grid.draw(pg2)
grid::grid.draw(pg3)
dims = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33)
pg1 <- profileglyphGrob(x = 200, y = 150, z = dims,
size = 25, lwd.bar = 5, width = 8,
line = FALSE)
pg2 <- profileglyphGrob(x = 500, y = 400, z = dims,
size = 25, lwd.bar = 5, width = 8,
linejoin = "round", line = FALSE)
pg3 <- profileglyphGrob(x = 800, y = 650, z = dims,
size = 25, lwd.bar = 5, width = 8,
linejoin = "bevel", line = FALSE)
grid::grid.newpage()
grid::grid.draw(pg1)
grid::grid.draw(pg2)
grid::grid.draw(pg3)
# lineend variants
dims = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33)
pg1 <- profileglyphGrob(x = 200, y = 150, z = dims,
size = 25, lwd.line = 5, width = 8)
pg2 <- profileglyphGrob(x = 500, y = 400, z = dims,
size = 25, lwd.line = 5, width = 8,
lineend = "butt")
pg3 <- profileglyphGrob(x = 800, y = 650, z = dims,
size = 25, lwd.line = 5, width = 8,
lineend = "square")
grid::grid.newpage()
grid::grid.draw(pg1)
grid::grid.draw(pg2)
grid::grid.draw(pg3)
# Bars with multiple fill colours
dims = c(0.24, 0.3, 0.8, 1.4, 0.6, 0.33)
bg1 <- profileglyphGrob(x = 200, y = 200, z = dims,
size = 20,
fill = RColorBrewer::brewer.pal(6, "Dark2"))
bpg1 <- profileglyphGrob(x = 700, y = 200, z = dims,
size = 20, line = FALSE,
fill = RColorBrewer::brewer.pal(6, "Dark2"))
bg2 <- profileglyphGrob(x = 350, y = 450, z = dims,
size = 20, mirror = FALSE,
fill = RColorBrewer::brewer.pal(6, "Dark2"))
bpg2 <- profileglyphGrob(x = 850, y = 450, z = dims,
size = 20, line = FALSE, mirror = FALSE,
fill = RColorBrewer::brewer.pal(6, "Dark2"))
bg3 <- profileglyphGrob(x = 200, y = 650, z = dims,
size = 20, flip.axes = TRUE,
fill = RColorBrewer::brewer.pal(6, "Dark2"))
bpg3 <- profileglyphGrob(x = 700, y = 650, z = dims,
size = 20, line = FALSE, flip.axes = TRUE,
fill = RColorBrewer::brewer.pal(6, "Dark2"))
bg4 <- profileglyphGrob(x = 350, y = 700, z = dims,
size = 20, mirror = FALSE, flip.axes = TRUE,
fill = RColorBrewer::brewer.pal(6, "Dark2"))
bpg4 <- profileglyphGrob(x = 850, y = 700, z = dims,
size = 20, line = FALSE, mirror = FALSE,
flip.axes = TRUE,
fill = RColorBrewer::brewer.pal(6, "Dark2"))
grid::grid.newpage()
grid::grid.draw(bg1)
grid::grid.draw(bpg1)
grid::grid.draw(bg2)
grid::grid.draw(bpg2)
grid::grid.draw(bg3)
grid::grid.draw(bpg3)
grid::grid.draw(bg4)
grid::grid.draw(bpg4)
# Grid lines
dims = c(1, 3, 2, 1, 2, 3)
gl <- split(x = rep(c(1, 2, 3), 6),
f = rep(1:6, each = 3))
bg1 <- profileglyphGrob(x = 150, y = 200, z = dims,
size = 10, width = 5,
draw.grid = TRUE, lwd.bar = 5,
grid.levels = gl, col.grid = "black")
bg2 <- profileglyphGrob(x = 400, y = 250, z = dims,
size = 10, width = 5, lwd.bar = 5,
draw.grid = TRUE, mirror = FALSE,
grid.levels = gl, col.grid = "black")
bg3 <- profileglyphGrob(x = 650, y = 200, z = dims,
size = 10, width = 5, flip.axes = TRUE,
draw.grid = TRUE, lwd.bar = 5,
grid.levels = gl, col.grid = "black")
bg4 <- profileglyphGrob(x = 800, y = 200, z = dims,
size = 10, width = 5, flip.axes = TRUE,
draw.grid = TRUE, mirror = FALSE,
grid.levels = gl, col.grid = "black",
lwd.bar = 5)
bg5 <- profileglyphGrob(x = 150, y = 500, z = dims,
size = 10, width = 5,
draw.grid = TRUE, lwd.bar = 5,
grid.levels = gl, col.grid = "white",
col.bar = "white", line = FALSE,
fill = RColorBrewer::brewer.pal(6, "Dark2"))
bg6 <- profileglyphGrob(x = 400, y = 550, z = dims,
size = 10, width = 5, lwd.bar = 5,
draw.grid = TRUE, mirror = FALSE,
grid.levels = gl, col.grid = "white",
col.bar = "white", line = FALSE,
fill = RColorBrewer::brewer.pal(6, "Dark2"))
bg7 <- profileglyphGrob(x = 650, y = 500, z = dims,
size = 10, width = 5, flip.axes = TRUE,
draw.grid = TRUE, lwd.bar = 5,
grid.levels = gl, col.grid = "white",
col.bar = "white", line = FALSE,
fill = RColorBrewer::brewer.pal(6, "Dark2"))
bg8 <- profileglyphGrob(x = 800, y = 500, z = dims,
size = 10, width = 5, flip.axes = TRUE,
draw.grid = TRUE, mirror = FALSE,
grid.levels = gl, col.grid = "white",
col.bar = "white", lwd.bar = 5, line = FALSE,
fill = RColorBrewer::brewer.pal(6, "Dark2"))
grid::grid.newpage()
grid::grid.draw(bg1)
grid::grid.draw(bg2)
grid::grid.draw(bg3)
grid::grid.draw(bg4)
grid::grid.draw(bg5)
grid::grid.draw(bg6)
grid::grid.draw(bg7)
grid::grid.draw(bg8)