Usage
Plot(x, y=NULL, data=mydata,
values=c("data", "count", "prop", "sum", "mean", "sd", "min",
"median", "max"),
n.cat=getOption("n.cat"), by=NULL, by2=NULL, by.group=NULL,
n.row=NULL, n.col=NULL, aspect="fill",
fill=getOption("fill.pt"), stroke=getOption("stroke.pt"),
bg=getOption("bg"), box=getOption("box"),
grid=getOption("grid"),
segment=getOption("stroke.pt"),
color=NULL, trans=NULL,
cex.axis=0.76, axes="gray30", xy.ticks=TRUE,
xlab=NULL, ylab=NULL, main=NULL, sub=NULL,
value.labels=NULL, label.max=20,
rotate.x=0, rotate.y=0, offset=0.5,
proportion=FALSE,
size=NULL, size.cut=NULL, shape="circle", means=TRUE,
sort.yx=FALSE, segments.y=FALSE, segments.x=FALSE,
ID="row.name", ID.cut=NULL, ID.color="gray50", ID.size=0.75,
radius=0.25, power=0.6, bubble.text="black",
low.fill=NULL, hi.fill=NULL,
smooth=FALSE, points.smooth=100, trans.smooth=0.25,
bins.smooth=128,
fit=FALSE, stroke.fit="gray20", lwd.fit=NULL, se.fit=0,
ellipse=FALSE, stroke.ellipse=getOption("stroke.pt"),
fill.ellipse=getOption("fill.ellipse"), lwd.ellipse=1,
method="overplot", pt.reg="circle", pt.out="circle",
out30="firebrick2", out15="firebrick4", new=TRUE,
boxplot=FALSE,
run=FALSE, lwd=2, area=FALSE, area.origin=0,
center.line=c("default", "mean", "median", "zero", "off"),
show.runs=FALSE, stack=FALSE,
bin.start=NULL, bin.width=NULL, bin.end=NULL,
breaks="Sturges", cumul=FALSE,
add=NULL, x1=NULL, y1=NULL, x2=NULL, y2=NULL,
add.cex=1, add.lwd=1, add.lty="solid",
add.stroke="gray50", add.fill=getOption("fill.pt"),
add.trans=NULL,
digits.d=NULL, quiet=getOption("quiet"), do.plot=TRUE,
width=NULL, height=NULL, pdf.file=NULL,
fun.call=NULL, …)
ScatterPlot(…)
sp(…)
Arguments
x
By itself, or with y
, by default a variable plotted by its
values mapped to coordinates. The data can be
continuous, categorical or a time series. If x
is sorted
with equal intervals
separating the values, or is a time series, then by default
plots the points sequentially, joined by line segments.
Can specify multiple x
-variables or multiple y
-variables
as vectors, but not both. Can be in a data frame or defined
in the global environment.
y
Variable with values to be mapped to coordinates of points in
the plot on the vertical axis. Can be continuous or categorical.
Can be in a data frame or defined in the global environment.
data
Optional data frame that contains one or both of x
and
y
. Default data frame is mydata
.
values
The values as coordinates from which to plot the points,
data values
by default. If only x
is specified,
then the statistics "count"
and "prop"
can be specified
for categories, or automatically binned values of a continuous variable.
If there is a second variable, y
, which is continuous, then
for either a categorical x
variable, or a continuous x
variable
with values binned into categories, then can apply "mean"
, etc.
n.cat
Number of categories, specifies the largest number of
unique, equally spaced integer values of variable for which
the variable will be analyzed as categorical.
Set to 0 to turn off, to force all such variables to be analyzed
as continuous.
by
A categorical variable called a conditioning variable that
activates Trellis graphics, from the lattice package, to provide
a separate scatterplot (panel) of numeric primary variables x
and y
for each level of the variable.
by2
A second conditioning variable to generate Trellis
plots jointly conditioned on both the by
and by2
variables,
with by2
as the row variable, which yields a scatterplot (panel)
for each cross-classification of the levels of numeric x
and
y
variables.
by.group
A categorical variable to provide a scatterplot for
each level of the numeric primary variables x
and
y
on the same plot, which applies to the panels of
a Trellis plot if by
is specified.
n.row
Optional specification for the number of rows in the layout
of a multi-panel display with Trellis graphics. Need not specify
n.col
.
n.col
Optional specification for the number of columns in the
layout of a multi-panel display with
Trellis graphics. Need not specify n.row
. If set to 1, then
the strip that labels each group locates to the left of each plot
instead of the top.
aspect
Lattice parameter for the aspect ratio of the panels,
defined as height divided by width.
The default value is "fill"
to have the panels
expand to occupy as much space as possible. Set to 1 for square panels.
Set to "xy"
to specify a ratio calculated
to "bank" to 45 degrees, that is, with the line slope approximately
45 degrees.
fill
The interior color of the plotted points or bubbles.
By default, is
a partially transparent version of the border color, stroke
.
If y
-values are unique, as in a Cleveland dot plot, then no
transparency by default as there can be no over-plotting. Remove with
fill="off"
. This
and the following colors can also be changed globally, individually and as
a color theme, with the lessR
global
function.
The lessR
function showColors
provides examples of all
R named colors. stroke
Border color of the plotted points, strokes,
or, if there is a line and
no points, color of the line. If there is a by
variable,
one value for each level of by
. Remove with stroke="off"
.
bg
Fill color of the plot area background. Remove with bg="off"
.
box
Color of border around the plot background, the box, that encloses
the plot. Remove with box="off"
.
grid
Color of the grid lines, a value of "on" restores the color from
the current global
if turned off by default as with a Cleveland dot
plot. Remove with grid="off"
.
segment
Color of connecting line segments when there are also plotted
points, such as in a frequency
polygon. Default color is stroke
.
color
Simultaneously specifies both stroke
and fill
, and
takes precedence over their individually specified values.
trans
Transparency level of plotted points from 0 (none) to 1 (complete).
For plotting data values, fill transparency is 0.25 to allow for overlap
of plotted points, otherwise set at 0 if overlap is not possible.
cex.axis
Scale magnification factor of the values on the axes.
axes
Color of the font used to label the axis values.
xy.ticks
Flag that indicates if tick marks and associated values on the
axes are to be displayed.
xlab
Label for x
-axis. If xlab
is not specified, then the label
becomes
the name of the corresponding variable label if it exists, or, if not, the
variable name. If xy.ticks
is FALSE
, then no label is displayed.
If no y variable is specified, then xlab
is set to Index unless
xlab
has been specified.
ylab
Label for y
-axis. If xlab
is not specified, then
the label becomes
the name of the corresponding variable label if it exists, or, if not, the
variable name. If xy.ticks
is FALSE
, then no label displayed.
main
Label for the title of the graph. If the corresponding variable
labels exist,
then the title is set by default from the corresponding variable labels.
sub
Sub-title of graph, below xlab
.
value.labels
Labels for the x
-axis on the graph to override
existing data values, including factor levels. If the variable is a
factor and value.labels
is not specified (is NULL
), then the
value.labels are set to the factor levels with each space replaced by
a new line character. If x
and y
-axes have the same scale,
they also apply to the y
-axis.
label.max
Maximum size of labels for the values of a categorical variable.
Not a literal maximum as preserving unique values may require a larger number
of characters than specified.
rotate.x
Degrees that the x
-axis values are rotated, usually to
accommodate longer values, typically used in conjunction with offset
.
rotate.y
Degrees that the y
-axis values are rotated.
offset
The spacing between the axis values and the axis. Default
is 0.5. Larger values such as 1.0 are used to create space for the label when
longer axis value names are rotated.
proportion
Specify proportions, relative frequencies, instead of counts.
For a two variable bar chart, if TRUE
then to facilitate group
comparisons, displays the proportion of data values by fill variable within
each group.
size
When set to a constant, the scaling factor for standard points
(not bubbles) or a line, with default of 1.0 for points and 2.0 for a line.
Set to 0 to not plot the points or lines. When set to a variable, activates a
bubble plot with the size of each bubble further determined
by the value of radius
.
size.cut
If TRUE
(or 1
), then for a bubble plot, show the value
of the sizing variable for a bubble in the center of selected bubbles,
unless the bubble is too small. If FALSE
, no value is displayed.
If a number greater than 1, then display the value only for the
corresponding quantiles, such as just the max and min for a setting of 2,
the default value when bubbles represent a size
variable. Color of the displayed text set by bubble.text
.
shape
The plot character(s). The default value is a circle with both an
stroke and filled area, specified with stroke
and fill
.
Possible values are circle
, square
, diamond
,
triup
(triangle up), tridown
(triangle down), all
uppercase and lowercase letters, all digits, and most punctuation characters.
The numbers 21 through 25 as defined by the R points
function
also apply. If plotting levels according to by
, then list one shape for
each level to be plotted. means
If the one variable is categorical the other variable continuous,
then if TRUE
, by default, plot means with the scatterplot. Also
applies to a 1-D scatterplot.
sort.yx
Sort the values of y
by the values of x
, such as
for a Cleveland dot plot, that is, a numeric x
-variable paired
with a categorical y
-variable with unique values. If a x
is a vector of two variables, sort by their difference.
segments.y
For one x
-variable, draw a line segment from the
y
-axis to
each plotted point, such as for the Cleveland dot plot. For two
x
-variables, the line segments connect the two points.
segments.x
Draw a line segment from the x
-axis for each plotted point.
ID
Name of variable to provide the labels for the plotted points,
row names by default.
ID.cut
Proportion of plotted points to label, in order of their
Mahalanobis distance from the scatterplot center, so that more extreme
points are labeled first. Defaults to 0 in
general for no labels, but for one or more ellipses, set to a value
of 1 minus the data level of the largest ellipse, reduced by 0.04.
ID.color
Color of the text to display the labels, with a default
of"gray50"
.
ID.size
Size of the plotted labels, with a default of 0.75 according
to the R parameter cex
.
radius
Scaling factor of the bubbles in a bubble plot, which
sets the radius of the largest displayed bubble in inches, with default of
0.25 inches. Can activate by setting the value of size
to
a third variable, which
sets the size of a bubble according to the size of the third variable.
Or activate when the values of the variables are categorical, either a
factor or an integer variable with the number of unique values less than
n.cat
, in which case the size of the bubbles represents
frequency.
power
Relative size of the scaling of the bubbles to each other.
Value of 0.5 scales the bubbles so that the area of each bubble is the
value of the corresponding sizing variable. Value of 1 scales so the
radius of the bubble
is the value of the sizing variable, increasing the discrepancy of size
between the variables. The default value is 0.6.
bubble.text
Color of the displayed text regarding the size of a bubble,
either a tabulated frequency for categorical variables, or the value of a
third variable according to size
.
low.fill
For a categorical variable and the resulting bubble plot,
or a matrix of these plots, sets a color gradient of the fill color
beginning with this color.
hi.fill
For a categorical variables and the resulting bubble plot,
or a matrix of these plots, sets a color gradient of the fill color
ending with this color.
smooth
Smoothed density plot for two numerical variables. By default,
set to TRUE
for 2500 or more rows of data.
points.smooth
Number of points superimposed on the density plot in the
areas of
the lowest density to help identify outliers, which controls how dark are the
smoothed points.
trans.smooth
Exponent of the function that maps the density scale to the
color scale.
bins.smooth
Number of bins in both directions for the density estimation.
fit
The best fit line. Default value is FALSE
, with
options for "loess"
and for least squares, indicated by
"ls"
. Or, if set to TRUE
, then a loess line. Invoking
any of the other fit parameters activates fit
.
stroke.fit
Color of the best fitting line.
lwd.fit
Width of fit line. By default is 2 for Windows and 1.5 for Mac.
se.fit
Number of standard errors to plot around the fit. The default
value of 0 turns off the standard error plot. Can be a vector to display
multiple ranges.
ellipse
If TRUE
, enclose a scatterplot of only a single
x
-variable
and a single y-variable with the default .95 data ellipse. Or can
specify a single or vector of numeric values greater than 0 and less than 1,
to plot one or more specified ellipses. The specified number of ellipses
for each level of by.group
. For Trellis graphics, only the
maximum level applies and only one ellipse per panel.
stroke.ellipse
Color of the ellipses, the strokes of the filled ellipses.
If specified, ellipse
is set to TRUE
.
fill.ellipse
If TRUE
, fill color of the ellipses, with the
default a highly
transparent version of the fill color of the applicable color theme.
If specified, ellipse
is set to TRUE
. Not applicable to
Trellis graphics.
lwd.ellipse
Line width of each ellipse.
method
Applies to a 1-variable scatter plot of a numerical variable,
sometimes called a dot plot. Default is "overplot"
, but can also set
to "jigger"
to scramble the points.
pt.reg
For 1-D scatterplot, type of regular (non-outlier) point. Default
is 21, a circle with specified fill.
pt.out
For a 1-D scatterplot, type of point for outliers. Default is 19, a
filled circle.
out30
For a 1-D scatterplot, color of outliers according to Tukey's
definition based on the IQR.
out15
For a 1-D scatterplot, color of potential outliers.
new
If FALSE
, then add the 1-D scatterplot to an existing graph.
boxplot
For a 1-D scatterplot, superimpose a box plot.
run
If set to TRUE
, generate a run chart, i.e., line chart,
in which
points are plotted in the sequential order of occurrence in the data table.
By default the points are connected by line
segments to form a run chart. Set by default when the x
-values
are sorted with equal intervals or a single variable is a time series.
lwd
Width of the line segments. Set to zero to remove the line
segments.
area
Color of the fill area under a curve, the area between the curve
and the axis. Can also be TRUE
, which sets to the fill color
for points, or a specific color can be specified. Default is TRUE
if
multiple time series are plotted.
area.origin
Origin for the filled area under the time series line. Values
less than this value are below the corresponding reference line, values
larger are above the line.
center.line
Plots a dashed line through the middle of a run chart. The two
possible values for the line are "mean"
and "median"
.
Provides a center line for the "median"
by default when the values
randomly vary about the mean. A value of "zero"
specifies the center
line should go through zero. Currently does not apply to Trellis plots.
show.runs
If TRUE
, display the individual runs in the run analysis.
Also sets run
to TRUE
.
stack
If TRUE
, multiple time plots are stacked on each other, with
area
set to TRUE
by default.
bin.start
Optional specified starting value of the bins for a frequency
polygon, when values
is set to "count"
or "prop"
for a continuous x
variable.
bin.width
Optional specified bin width value.
bin.end
Optional specified value that is within the last bin, so the
actual endpoint of the last bin may be larger than the specified value.
breaks
The method for calculating the bins, or an explicit specification of
the bins, such as with the standard R seq
function or other
options provided by the hist
function. cumul
Specify a cumulative frequency polygon.
add
Draw one or more objects, text or a geometric figures,
on the plot.
Possible values are any text to be written, or, to indicate a figure,
"text"
, "rect"
(rectangle), "line"
, "arrow"
,
"v.line"
(vertical line), and "h.line"
(horizontal line).
The value "means"
is short-hand for vertical and horizontal lines
at the respective means. Does not apply to Trellis graphics.
x1
First x coordinate to be considered for each object, can be
"mean.x"
. Not used for "h.line"
.
y1
First y coordinate to be considered for each object, can be
"mean.y"
. Not used for"v.line"
.
x2
Second x coordinate to be considered for each object, can be
"mean.x"
. Only used for "rect"
, "line"
and
arrow
.
y2
Second y coordinate to be considered for each object, can be
"mean.y"
. Only used for "rect"
, "line"
and
arrow
.
add.cex
Text expansion factor, relative to 1. As with the following
properties, can be a vector for multiple placement or objects.
add.lwd
Line width of added object.
add.lty
Line type of added object.
add.stroke
Color of borders and lines of added object.
add.fill
Interior fill color of added object.
add.trans
Transparency level of stroke or fill, which ever is
applicable from 0 (opaque) to 1 (transparent).
digits.d
Number of significant digits for each of the displayed summary
statistics.
quiet
If set to TRUE
, no text output. Can change system default
with global
function. do.plot
If TRUE
, the default, then generate the plot.
width
Width of the plot window in inches, defaults to 5 except in RStudio
to maintain an approximate square plotting area.
height
Height of the plot window in inches, defaults to 4.5 except for
1-D scatterplots and when in RStudio.
pdf.file
Indicate to direct pdf graphics to the specified name of
the pdf file.
fun.call
Function call. Used with knitr
to pass the function call when
obtained from the abbreviated function call sp
.
…
Other parameter values for non-Trellis graphics as defined by and
processed by standard R functions plot
and par
,
including
xlim
and ylim
for setting the range of the x
and
y
-axes
cex.main
for the size of the title
col.main
for the color of the title
cex
for the size of the axis value labels
cex.lab
for the size of the axis labels
col.lab
for the color of the axis labels
lty
for line type, such as "solid"
, "dashed"
,
"dotted"
, "dotdash"
sub
and col.sub
for a subtitle and its color
For one continuous variable, parameters from stripchart