Learn R Programming

svgViewR (version 1.4.3)

svg.points: Write points to SVG Viewer

Description

Draws a sequence of points at specified coordinates in an SVG Viewer.

Usage

svg.points(x, y=NULL, type="p", col=NULL, col.fill="black", 
               col.stroke="black", z.index=0, layer="", label="", 
               cex=2, lwd=2, opacity.stroke=1, opacity.fill=1, 
               file=NULL)

Value

NULL

Arguments

x

A vector, matrix or array of 2D or 3D coordinates. Coordinates input as an array will be animated.

y

If x is a vector, the coordinates on the y-axis.

type

character indicating the type of plotting. Currently, only "p" is supported.

col

The fill and stroke color of the points(s). If non-NULL, col overrides col.fill and col.stroke.

col.fill

The fill color of the points(s).

col.stroke

The stroke (border) color of the points(s).

z.index

A number indicating the relative order in which the SVG object will be drawn in the viewer. Higher numbers correspond to closer to the front or top.

layer

A text string indicating the layer in which the SVG object belongs (not yet fully implemented).

label

A label to be added to the SVG object in SVG tag.

cex

The size (radius) of the point(s).

lwd

The thickness of the border of the point(s).

opacity.stroke

A number between 0 and 1 indicating the opacity of the border of the point(s).

opacity.fill

A number between 0 and 1 indicating the opacity of the fill of the point(s).

file

File path (having the extenstion ".html") to add lines to a current SVG Viewer file. By default (i.e. NULL) lines are added to the SVG Viewer opened by svg.new.

Author

Aaron Olsen

Details

This function accepts input similar to the native plot function points(). If x and y are vectors, they are combined into a matrix using cbind(). If x is a matrix, this matrix is used directly. Each row of the matrix is drawn as a point. If x is an array, the array is interpreted as a series of matrices, each representing a state of the point or point(s) in an animation of length dim(x)[3]. Each of the dim(x)[3] matrices is used to draw each state in a manner identical to when x is a matrix. If x is an array, each state of points will be drawn as an animation.

The graphical parameters col, col.fill, col.stroke, z.index, layer, label, lwd, opacity.stroke and opacity.fill can all be vectors of length one or of the same length as the number of points to be drawn. This allows different parameters to be specified for each point.

See Also

svg.new, svg.lines, svg.pathsC

Examples

Run this code
if (FALSE) {
## Create animated sinusoid
# Create new viewer
svg.new(file='svgviewr.html', animate.duration=1)

# Create points with varying sin phase
n <- 100
x <- array(NA, dim=c(40, 2, n))
x_seq <- seq(-pi, pi, length=dim(x)[1])
n_seq <- seq(0, 2*pi, length=n)
for(i in 1:dim(x)[3]) x[, , i] <- cbind(x_seq, sin(x_seq + n_seq[i]))

# Draw points
svg.points(x, cex=2, lwd=1, col="blue")

# Close viewer connection
svg.close()

# Open svgviewr.html to visualize
}

Run the code above in your browser using DataLab