Plotting: Low-Level Functions

DESCRIPTION:

Draw high-low-open-close (HLOC) indicators, stacked bars, or lines/points on a plot.

USAGE:

hloc.render(x, hloc, high=NULL, low=NULL, open=NULL, close=NULL,  
            style="l", x.scale=NULL, y.scale=NULL, width=0.01,  
            col=<<see below>>, lwd=1, lty=1) 
stackbar.render(x, y, cum=F, x.scale = NULL, y.scale = NULL,  
                width = 0.01, x.width, lwd=1, lty=1, 
                line.col=fill.col, fill.col=<<see below>>, density=-1, 
                angle=45) 
lines.render(x, y, type="l", x.scale = NULL, y.scale = NULL,  
             lty=<<see below>>, col=<<see below>>, lwd=<<see below>>,  
             pch=<<see below>>, font=<<see below>>, cex=<<see below>>) 

REQUIRED ARGUMENTS:

x
x values for the HLOC indicators or stacked bars.
y
y values for the stacked bars or lines: a vector, data frame or matrix, where each row corresponds to one x value, and each column represents one layer in the stack of bars or one set of y coordinates to plot.

OPTIONAL ARGUMENTS:

hloc
data frame or matrix with columns named (case-insensitive) "high", "low", "open", and "close", which will override values given in high, low, open, and close if given.
high
y high value; required if style="l".
low
y low value; required if style="l".
open
y open value; required if style="c".
close
y close value; required if style="c".
style
style of HLOC indicators. "c" for so-called "candlesticks", which have vertical lines running from low to high, broken by a rectangular box from open to close. The rectangular box is filled if close is lower than open, and unfilled if open is lower than close. "l" for vertical lines running from low to high, with a tick mark to the left for open and to the right for close.
x.scale
the scale to use for the x-coordinates. Can be NULL if the x coordinates are in what plot considers to be the user coordinates for the plot. If the coordinates are given as calendar times or in user coordinates which are piecewise-linear transformations of plot coordinates, then scale is a 2-element list where the first element is a monotonic sequence in user-coordinates giving the endpoints of the linear regions, and the second element is the plot coordinates of those points. Points which lie outside the scale region will be moved to the ends and a warning will generated.
y.scale
the scale to use for the y-coordinates, as in x.scale.
width
width of the open-close indicator boxes or ticks (for hloc.render), or of the bars (for stackbar.render) as a fraction of the minimum of the length and width of the plot.
col
color, as in par. For lines.render this can also be a vector of colors for each set of lines or points. Default comes from trellis.par.get("plot.line") for hloc.render. For lines.render, default value comes from trellis.par.get("superpose.line") unless type="p", in which case it comes from trellis.par.get("superpose.symbol").
cum
if T, the y values are given as the total cumulative heights of bars; if F, the y values are the heights of the individual bar sections.
x.width
width of the bars in terms of x-coordinate scaled units, overrides the width argument if present.
lwd
line width for the bar outlines or plotting lines, as in par; this can also be a vector giving the line width for each level of bar or plotting line. For lines.render, default value comes from trellis.par.get("superpose.line").
lty
line type for the bar outlines or plotting lines, as in par; this can also be a vector giving the line type for each level of bar or each line. For lines.render, default value comes from trellis.par.get("superpose.line").
line.col
color for the bar outlines, as in par("col"); this can also be a vector giving the line color for each level of bar.
fill.col
color for filling the bars, as in par("col"); this can also be a vector giving the fill color for each level of bar. Default comes from trellis.par.get("pie.fill").
density
density of shading lines for the bars, in lines per inch, or -1 to fill solidly; this can also be a vector giving the density for each level of bar.
angle
angle of shading lines for the bars, in degrees counterclockwise from horizontal; this can also be a vector giving the angle for each level of bar.
type
type of lines or points to plot: "p", "l", "b", "o", "n", "s", and "h" produce points, lines, both, both (overlaid), nothing, stairsteps, and high-density lines, respectively. This can also be a vector giving the type for each set of y coordinates.
pch
plotting character, as in par; this can also be a vector giving the plotting character for each set of y coordinates. For lines.render, default value comes from trellis.par.get("superpose.symbol").
cex
character expansion, as in par; this can also be a vector giving the character expansion for each set of y coordinates. For lines.render, default value comes from trellis.par.get("superpose.symbol").
font
character font, as in par; this can also be a vector giving the character font for each set of y coordinates. For lines.render, default value comes from trellis.par.get("superpose.symbol").

VALUE:

NULL.

SIDE EFFECTS:

Causes HLOC indicators, stacked bars, lines, or points to be added to the current plot.

DETAILS:

These low-level plotting functions are similar to the lines or points functions, but they allow other types of plot indicators and include scaling.

REFERENCES:

See the chapter "Creating Plots" in the S-PLUS User's Guide for a more detailed description of candlestick plots.

SEE ALSO:

.

EXAMPLES:

mydata <- list(x = 1:10, high = 15:24, low = 11:20, open = 12:21, 
               close = 14:23) 
yinit <- mydata$low; yinit[10] <- 24 
plot(mydata$x, yinit, type = "n") 
hloc.render(mydata$x, high=mydata$high, low=mydata$low, open=mydata$open,  
    close=mydata$close) 
plot(mydata$x, yinit, type = "n") 
stackbar.render(mydata$x, data.frame(mydata$low, mydata$high), cum=T) 
lines.render(mydata$x, mydata$low)