Grid-Based 'symbols' Function

Description

Similar to symbols function, but drawn in grid viewport: This function draws symbols on a plot. One of six symbols; circles, squares, rectangles, stars, thermometers, and boxplots, can be plotted at a specified set of x and y coordinates. Specific aspects of the symbols, such as relative size, can be customized by additional parameters.

Usage

1
2
3
gsymbols(x, y = NULL, circles, squares, rectangles,
         stars, thermometers, boxplots, 
         fg = par("col"), bg = par("col"), ...)

Arguments

x, y

x and y co-ordinates for the centres of the symbols.

circles

a vector giving the radii of the circles.

squares

a vector giving the length of the sides of the squares.

rectangles

a matrix with two columns. The first column gives widths and the second the heights of rectangles.

stars

a matrix with three or more columns giving the lengths of the rays from the center of the stars. NA values are replaced by zeroes.

thermometers

a matrix with three or four columns. The first two columns give the width and height of the thermometer symbols. If there are three columns, the third is taken as a proportion: the thermometers are filled (using colour fg) from their base to this proportion of their height. If there are four columns, the third and fourth columns are taken as proportions and the thermometers are filled between these two proportions of their heights. The part of the box not filled in fg will be filled in the background colour (default transparent) given by bg.

boxplots

a matrix with five columns. The first two columns give the width and height of the boxes, the next two columns give the lengths of the lower and upper whiskers and the fifth the proportion (with a warning if not in [0,1]) of the way up the box that the median line is drawn.

fg

colour(s) the symbols are to be drawn in.

bg

if specified, the symbols are filled with colour(s), the vector bg being recycled to the number of symbols. The default is to leave the symbols unfilled.

...

arguments, passed to basic grid functions (e.g. gpar()

Author(s)

Ingo Voglhuber

See Also

gbarplot, gmatplot, gpie, gstars, gbxp

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
grid.newpage()

## circles.
data(trees)
attach(trees)
gsymbols(Height,Volume,circles=Girth/8)

grid.newpage()

N <- nrow(trees)
palette(rainbow(N, end = 0.9))
gsymbols(Height,Volume,circles=Girth/8,gp=gpar(fill=1:N))

grid.newpage()

## squares.
data(trees)
attach(trees)
gsymbols(Height,Volume,squares=Girth/8)

grid.newpage()

N <- nrow(trees)
palette(rainbow(N, end = 0.9))
gsymbols(Height,Volume,squares=Girth/8,gp=gpar(fill=1:N))

grid.newpage()

## rectangles.
data(trees)
attach(trees)
gsymbols(Height,Volume,rectangles=cbind(Girth/6,Girth/8))
grid.newpage()
N <- nrow(trees)
palette(rainbow(N, end = 0.9))
gsymbols(Height,Volume,rectangles=cbind(Girth/6,Girth/8),
             gp=gpar(fill=1:N))

grid.newpage()

## thermometers.
x <- 1:10
y <- sort(10 * runif(10))
z <- runif(10)
z <- cbind(z, 2 * runif(10), runif(10))
gsymbols(x,y,thermometers=z)

grid.newpage()

gsymbols(x,y,thermometers=z,fg=1:10)
grid.newpage()
gsymbols(x,y,thermometers=z,fg=1:10,bg=1:10)

grid.newpage()

## boxplots.
x <- 1:5
y <- sort(10 * runif(5))
z <- cbind(1.5*runif(5),1.5*runif(5),runif(5)/2,
           runif(5)/2,runif(5))
gsymbols(x,y,boxplots=z,gp = gpar(col="blue"))

grid.newpage()

## stars.
x <- 1:5
y <- 1:5
z <- cbind(1.5*runif(3),1.5*runif(3),runif(3)/2,
           runif(3)/2,runif(3),runif(3))
gsymbols(x,y,stars=z,gp = gpar(col="blue"))

grid.newpage()

x <- 1:3
y <- 1:3
z <- cbind(runif(15),runif(15),runif(15),runif(15))
gsymbols(x,y,stars=z,gp = gpar(col="blue"))