Learn R Programming

TeachingDemos (version 2.7)

ms.polygram: Symbol functions/data to be passed as symb argument to my.symbols

Description

These functions/data matricies are examples of what can be passed as the symb argument in the my.symbols function. They are provided both to be used for some common symbols and as examples of what can be passed as the symb argument.

Usage

ms.polygram(n, r=1, adj=pi/2, ...)
ms.polygon(n, r=1, adj=pi/2, ...)
ms.filled.polygon(n, r=1, adj=pi/2, fg=par('fg'), bg=par('fg'), ... )
ms.male
ms.female
ms.arrows(angle, r=1, adj=0.5, length=0.1, ...)
ms.sunflowers(n,r=0.3,adj=pi/2, ...)
ms.image(img, transpose=TRUE, ...)

Arguments

n
The number of sides for polygons and polygrams, the number of petals(lines) for sunflowers.
r
The radius of the enclosing circle for polygons and polygrams (1 means that it will pretty much fill the bounding square). For sunflowers this is the radius (relative to the inches square) of the inner circle. For arrows this controls the lengt
adj
For polygons, polygrams, and sunflowers this is the angle in radians that the first corner/point will be. The default puts a corner/point straight up, this can be used to rotate the symbols. For arrows, this determines the positioning of the ar
fg, bg
Colors for the filled polygons. fg is the color of the line around the polygon and bg is the fill color, see polygon.
angle
The angle in radians that the arrow will point.
length
The length of the arrow head (see arrows).
img
A 3 dimensional array representing an image such as produced by the png or EBImage packages.
transpose
Should the image be tranposed, use TRUE for images imported using package png and FALSE for images imported using EBImage.
...
additional parameters that will be passed to plotting functions or be ignored.

Value

  • These functions either return a 2 column matrix of points to be passed to lines or NULL.

Details

These functions/matricies can be passed as the symb argument to the my.symbols function. The represent examples that can be used to create your own symbols or may be used directly.

See Also

my.symbols, polygon, arrows, lines

Examples

Run this code
plot(1:10,1:10)
my.symbols(1:10,1:10, ms.polygram, n=1:10, r=seq(0.5,1,length.out=10),
inches=0.3)

my.symbols(1:10,1:10, ms.polygon, n=1:10, add=FALSE, inches=0.3)

my.symbols(1:5, 5:1, ms.filled.polygon, add=FALSE, n=3:7, fg='green',
  bg=c('red','blue','yellow','black','white'), inches=0.3 )

my.symbols( 1:10, 1:10, ms.female, inches=0.3, add=FALSE)
my.symbols( 1:10, 10:1, ms.male, inches=0.3, add=TRUE)

plot(1:10, 1:10)
my.symbols(1:10, 1:10, ms.arrows, angle=runif(10)*2*pi, inches=0.5,
adj=seq(0,1,length.out=10), symb.plots=TRUE)

my.symbols(1:10, 1:10, ms.sunflowers, n=1:10, inches=0.3, add=FALSE)

if( require(png) ) {
  img <- readPNG(system.file("img", "Rlogo.png", package="png"))

  my.symbols( runif(10), runif(10), ms.image, MoreArgs=list(img=img),
                 inches=0.5, symb.plots=TRUE, add=FALSE)
}

Run the code above in your browser using DataLab