scatterPlot: Produce high-quality scatter plots

Description Usage Arguments Details Value Note See Also

View source: R/scatterPlot.R

Description

Plotting function with scads of options for creating high quality scatter plots. Can be used with screenPage.

Usage

 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
scatterPlot(x, y, 
            plotType = "p",
            lineType = "solid", lineWidth = 1.5,
            plotChar = "*", dataCex = 1,
            color = "black",
            xAxisMin = NULL, xAxisMax = NULL, xExpandBy = 0.04,
            xTicks = 5, xTickLocations = NULL,
            labelXTicks = TRUE, xTickLabels = NULL,
            xCex = 1, xAxisLabel = NULL, labelXAxis = TRUE, xSpace = 4,
            yAxisMin = NULL, yAxisMax = NULL, yExpandBy = 0.04,
            yTicks = 5, yTickLocations = NULL,
            yTickLabels = NULL, labelLeftTicks = FALSE, labelRightTicks = TRUE,
            yCex = 1, extendTopTick = TRUE,
            leftAxisLabel = NULL, rightAxisLabel = NULL,
            labelLeftAxis = TRUE, labelRightAxis = FALSE,
            cex = 1,
            head = NULL, headAlign = 0.5, headCex = 1.5,
            sub = NULL, subCex = 0.85,
            leftTopLabel = NULL, rightTopLabel = NULL, topLabelAlign = 0,
            labCex = 1, leftInsideLabel = NULL, rightInsideLabel = NULL,
            innerOffset = 0.05, innerCex = 0.8,
            foot = NULL, footAlign = 0, footCex = 0.8, footSpace = -1,
            tck = 0.03, axisWidth = 2, boxType = "u",
            leftMargin = -1, rightMargin = -1,
            topMargin = -1, bottomMargin = -1)

Arguments

x

the x coordinates of points in the plot. If this is a string, the function evalOrEcho will attempt to evaluate the string to obtain the x coordinates.

y

the y coordinates of points in the plot. If this is a string, the function evalOrEcho will attempt to evaluate the string to obtain the y coordinates.

plotType

type of plot desired. Values are "p" for points (the default), "l" for lines, "b" for both points and lines (lines miss the points), and "o" for overlaid points and lines.

lineType

character or numeric vector specifying the line type if plotType calls for lines. Default is "solid". For most devices, type 1 is solid, 2 is dotted, 3 and up are a mix of dots and dashes.

lineWidth

default is 1.5.

plotChar

character (or number for plotting symbols – see the help for points for details) to be used for plotting points. Default is "*".

dataCex

cex times this number gives the character expansion factor for the data points. Default is 1.

color

string or number. Default is 1, the device default foreground color.

xAxisMin

minimum value of the x axis. If non-NULL, this overrides the calculation described in xExpandBy.

xAxisMax

maximum value of the x axis. If non-NULL, this overrides the calculation described in xExpandBy.

xExpandBy

a single number or two numbers between 0 and 1. xAxisMin and xAxisMax will be calculated by multiplicatively extending the data range in both directions by these amounts. Default value .04 extends the data range by 4% in each direction.

xTicks

number of ticks to draw on x axis at "pretty" locations. Default is 5. This argument is ignored if xTickLocations is non-NULL.

xTickLocations

if non-NULL, a vector of desired tick locations or a string that evaluates to such a vector. The default value NULL lets the setting for xTicks take effect.

labelXTicks

If TRUE, label ticks on the x axis. Default is FALSE.

xTickLabels

character vector of tick labels or NULL (the default). If NULL and labelXTicks is TRUE, labels are constructed from the tick locations. This argument has no effect if labelXTicks is FALSE.

xCex

cex times this number gives the character expansion factor for the x-axis labels. Default is 1.

xAxisLabel

text to appear centered under the x axis. Default value NULL creates a string by deparsing the xargument. This argument is ignored if labelXAxis is FALSE.

labelXAxis

if TRUE (the default), label the x axis according to xAxisLabel.

xSpace

lines of space to set aside directly beneath the x-axis to hold tick, year and/or axis labels. Default is 4. The space created is xSpace times labCex.

yAxisMin

minimum value of the y axis. If non-NULL, this overrides the calculation described in yExpandBy.

yAxisMax

maximum value of the y axis. If non-NULL, this overrides the calculation described in yExpandBy.

yExpandBy

a single number or two numbers between 0 and 1. yAxisMin and yAxisMax will be calculated by multiplicatively extending the data range in both directions by these amounts. Default value .04 extends the data range by 4% in each direction.

yTicks

number of ticks to draw on y axis at "pretty" locations. Default is 5. This argument is ignored if yTickLocations is non-NULL.

yTickLocations

if non-NULL, a vector of desired tick locations or a string that evaluates to such a vector. The default value NULL lets the setting for yTicks take effect.

yTickLabels

character vector of tick labels or NULL (the default). If NULL and labelLeftTicks or labelRightTicks is TRUE, labels are constructed from the tick locations. This argument has no effect if labelLeftTicks and labelRightTicks are both FALSE.

labelLeftTicks

If TRUE, label ticks on the left axis. Default is FALSE.

labelRightTicks

If TRUE, label ticks on the left axis. Default is TRUE.

yCex

cex times this number gives the character expansion factor for the left and right axis labels. Default is 1.

extendTopTick

if TRUE (the default) the top tick of the y axes encloses the panel. leftAxisMax and rightAxisMax are increased as necessary to include the top tick for enclosing the panel.

leftAxisLabel

text to appear centered outside the left axis. Default value NULL creates a string by deparsing the y argument. This argument is ignored if labelLeftAxis is FALSE.

labelLeftAxis

if TRUE (the default), label the left axis according to leftAxisLabel.

rightAxisLabel

text to appear centered outside the right axis. Default value NULL creates a string by deparsing the y argument. This argument is ignored if labelRightAxis is FALSE.

labelRightAxis

if TRUE label the right axis according to rightAxisLabel. Default is FALSE

cex

the base character expansion factor by which all of the ***cex parameters are scaled. The default setting is the value of par("cex").

head

text to appear at the top of the figure region, with alignment determined by headAlign. No default.

headAlign

number indicating justification for the strings in head and sub. 0 means left justify, 1 means right justify, 0.5 (the default) means to center the text. Other numbers are a corresponding distance between the extremes.

headCex

cex times this number gives the character expansion factor for head. Default is 1.5.

sub

text to appear just under head, with alignment determined by headAlign. No default.

subCex

cex times this number gives the character expansion factor for sub. Default is 0.85.

leftTopLabel

text to appear at the top of the left axis, with alignment determined by topLabelAlign. No default.

rightTopLabel

text to appear at the top of the right axis, with alignment determined by topLabelAlign. No default.

topLabelAlign

number indicating alignment for the strings in leftTopLabel. 0 (the default) means left justify, 1 means right justify, 0.5 means to center the text. rightTopLabel, if given, is aligned by 1 - topLabelAlign.

labCex

cex times this number gives the character expansion factor for leftTopLabel, rightTopLabel, and xAxisLabel.

leftInsideLabel

text to appear left justified and just inside the upper left corner of the plot region. No default.

rightInsideLabel

text to appear right justified and just inside the upper right corner of the plot region. No default.

innerOffset

number between 0 and 1, a fractional offset for the inside labels. The left edge of leftInsideLabel is offset by this fraction of the x range from the left edge of the plot, as is the right edge of rightInsideLabel from the right edge of the plot.

innerCex

cex times this number gives the character expansion factor for leftInsideLabel and rightInsideLabel.

foot

text to appear at the bottom of the figure region, with alignment determined by footAlign. No default.

footAlign

number indicating justification for the strings in foot. 0 (the default) means left justify, 1 means right justify, 0.5 means to center the text. Other numbers are a corresponding distance between the extremes.

footCex

cex times this number gives the character expansion factor for foot. Default is 0.8.

footSpace

lines of space to set aside directly beneath the space allocated by xSpace to hold footnotes. The space created is footSpace times footCex. Default is length(foot); using a higher value will result in extra space in the bottom figure margin.

tck

length of major tick marks in inches. Minor ticks are 2/3 as long. Default is 0.03.

axisWidth

line width for the axes and box (if any). Default is 2.

boxType

character representing the type of box. Characters "o", "l" (ell), "7", "c" will produce boxes which resemble the corresponding upper-case letters. The value "n" will suppress boxes. The default is "u".

leftMargin

lines of space for the left margin. Default value (-1) figures this out automatically.

rightMargin

lines of space for the right margin. Default value (-1) figures this out automatically.

topMargin

lines of space for the top margin. Default value (-1) figures this out automatically.

bottomMargin

lines of space for the bottom margin. Default value (-1) figures this out automatically.

Details

Each of the text items head, sub, leftTopLabel, rightTopLabel, leftInsideLabel, rightInsideLabel, foot, leftAxisLabel, rightAxisLabel and xAxisLabel can be given as a string, a collections of strings, or as a string that gets evaluated to one of the first two. Multiple strings are drawn on successive lines.

Value

scatterPlot invisibly returns a list of class "scatterPlot" and elements named xy (a matrix containing x and y in two columns), plotType, lineType, color, plotChar, lineWidth, x (x coordinate for legend), y (y coordinate for legend), xRange, yRange, innerCex and par. This list is useful mostly as an argument to legend.

Note

scatterPlot is a companion to tisPlot. Both are designed to be driven from a graphical user interface.

See Also

tisPlot, evalOrEcho


tis documentation built on Sept. 29, 2021, 1:06 a.m.