Plotting function with scads of options for creating high quality scatter
plots. Can be used with screenPage
.
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)
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.
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.
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.
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.
default is 1.5
.
character (or number for plotting symbols -- see the help for
points
for details) to be used for plotting points.
Default is "*".
cex
times this number gives the character
expansion factor for the data points. Default is 1.
string or number. Default is 1, the device default foreground color.
minimum value of the x axis. If non-NULL, this overrides the
calculation described in xExpandBy
.
maximum value of the x axis. If non-NULL, this overrides the
calculation described in 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.
number of ticks to draw on x axis at "pretty" locations. Default
is 5. This argument is ignored if xTickLocations
is
non-NULL.
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.
If TRUE
, label ticks on the x axis. Default is FALSE
.
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
.
cex
times this number gives the character expansion factor
for the x-axis labels. Default is 1.
text to appear centered under the x axis. Default value NULL creates
a string by deparsing the x
argument. This argument is ignored
if labelXAxis
is FALSE
.
if TRUE
(the default), label the x axis according to
xAxisLabel
.
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
.
minimum value of the y axis. If non-NULL, this overrides the
calculation described in yExpandBy
.
maximum value of the y axis. If non-NULL, this overrides the
calculation described in 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.
number of ticks to draw on y axis at "pretty" locations. Default
is 5. This argument is ignored if yTickLocations
is
non-NULL.
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.
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
.
If TRUE
, label ticks on the left axis. Default is FALSE
.
If TRUE
, label ticks on the left axis. Default is TRUE
.
cex
times this number gives the character expansion factor
for the left and right axis labels. Default is 1.
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.
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
.
if TRUE
(the default), label the left axis according to
leftAxisLabel
.
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
.
if TRUE
label the right axis according to
rightAxisLabel
. Default is FALSE
the base character expansion factor by which all of the
***cex
parameters are scaled. The default setting is the
value of par("cex")
.
text to appear at the top of the figure region, with alignment
determined by headAlign
. No default.
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.
cex
times this number gives the character expansion factor
for head
. Default is 1.5.
text to appear just under head
, with alignment determined by
headAlign
. No default.
cex
times this number gives the character expansion factor
for sub
. Default is 0.85.
text to appear at the top of the left axis, with alignment
determined by topLabelAlign
. No default.
text to appear at the top of the right axis, with alignment
determined by topLabelAlign
. No default.
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
.
cex
times this number gives the character expansion factor
for leftTopLabel
, rightTopLabel
, and xAxisLabel
.
text to appear left justified and just inside the upper left corner of the plot region. No default.
text to appear right justified and just inside the upper right corner of the plot region. No default.
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.
cex
times this number gives the character expansion factor
for leftInsideLabel
and rightInsideLabel
.
text to appear at the bottom of the figure region, with alignment
determined by footAlign
. No default.
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.
cex
times this number gives the character expansion factor
for foot
. Default is 0.8.
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.
length of major tick marks in inches. Minor ticks are 2/3 as long. Default is 0.03.
line width for the axes and box (if any). Default is 2.
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"
.
lines of space for the left margin. Default value (-1) figures this out automatically.
lines of space for the right margin. Default value (-1) figures this out automatically.
lines of space for the top margin. Default value (-1) figures this out automatically.
lines of space for the bottom margin. Default value (-1) figures this out automatically.
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
.
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.