Usage
Plot(x, y=NULL, by=NULL, data=mydata, n.cat=getOption("n.cat"), values=c("data", "count", "prop", "sum", "mean", "sd", "min",
"median", "max"),
fill=getOption("fill.pt"),
stroke=getOption("stroke.pt"),
bg=getOption("bg"),
grid=getOption("grid"),
box=getOption("box"),
segment=getOption("fill.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.values=0, offset=0.5, proportion=FALSE,
size=NULL, shape="circle", means=TRUE,
sort.yx=FALSE,
segments.y=FALSE, segments.x=FALSE,
bubble.scale=0.25, bubble.power=0.6, bubble.text=NULL,
low.color=NULL, hi.color=NULL,
smooth=FALSE, smooth.points=100, smooth.trans=0.25,
smooth.bins=128,
fit=NULL, stroke.fit=getOption("stroke.bar"),
se.fit=0,
ellipse=FALSE, stroke.ellipse=getOption("stroke.pt"),
fill.ellipse=getOption("fill.ellipse"),
method="overplot", pt.reg="circle", pt.out="circle",
out30="firebrick2", out15="firebrick4", new=TRUE,
boxplot=FALSE,
line.chart=FALSE, line.width=2, area=FALSE,
center.line=c("default", "mean", "median", "zero", "off"),
show.runs=FALSE, stack=FALSE,
breaks="Sturges", bin.start=NULL, bin.width=NULL, bin.end=NULL,
cumul=FALSE,
digits.d=NULL, quiet=getOption("quiet"),
width=NULL, height=NULL, pdf.file=NULL,
fun.call=NULL, …)
ScatterPlot(…)
sp(…)
Arguments
x
If both x and y are specified, then the x-values are the coordinates
plotted on the horizontal axis. If x is sorted with equal intervals
separating the values, or is a time series, then the default is to
join the points with line segments. Specify multiple x-variables or
multiple y-variables, but not both.
y
Coordinates of points in the plot on the vertical axis.
by
An optional grouping variable such that the points of all (x,y) pairs are
plotted in the same plotting symbol and/or same color, with a different symbol
or symbol and/or color for each group.
data
Optional data frame that contains one or both of the variables of
interest, default is mydata
.
n.cat
Specifies the largest number of unique values of variable of a
numeric data type for which the variable will be analyzed as categorical
so as to generate a bubble plot. Set to 0 to turn off.
values
The plotted values according to their coordinates, data values
by default. For a categorical variable, if only x
is specified,
then the statistics "count"
and "prop"
can be specified
for the categories.
If there is a second variable, y
, which is continuous, then x
for either a categorical variable, or a continuous variable
with values binned into categories, then can apply "mean"
.
fill
For plotted points, the interior color of the points. 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"
.
stroke
Border color of the plotted points. If there is a by
variable,
specified as a vector, one value for each level of by
. Remove with
stroke="off"
.
bg
Color of the plot background. Remove with bg="off"
.
grid
Color of the grid lines, a value of "on" restores the color from
the current theme
if turned off by default as with a Cleveland dot
plot. Remove with grid="off"
.
box
Color of border around the plot background, the box, that encloses
the plot. Remove with box="off"
.
segment
Color of connecting line segments, such as in a frequency
polygon. Default color is stroke
. Remove with segment="off"
.
color
Simultaneously specifies both stroke
and fill
, and
takes precedence over their individually specified values.
trans
Transparency level from 0 (none) to 1 (complete). For plotting data
values, transparency is 0.5 to allow for overlap of plotted points,
otherwise set at 0.
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.values
Degrees that the axis values are rotated, usually to accommodate
longer values, typically used in conjunction with offset
.
offset
The amount of 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 expressed as a variable in
which case a bubble plot is activated with the size of each bubble determined
by the value of bubble.scale
.
shape
The plot character(s). The default value is a circle with both a border
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 first variable is a factor and the other variable continuous,
then if TRUE
, by default, plot means with the 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 two x-variables, sort by their difference.
segments.y
For one x-variable, draw line segments from y-axis to plotted point,
such as for the Cleveland dot plot. For two x-variables, the line segments
connect the two points.
segments.x
Draw line segments from the x-axis to plotted point.
bubble.scale
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. Compare to size
for the scaling of regular plotted points
when set to a constant.
bubble.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
If TRUE
(or 1
), then for a bubble plot, the value
of the sizing variable for a bubble is displayed in the center of selected bubbles,
unless the bubble is too small. If FALSE
, no text is displayed.
If a number greater than 1, then the text is displayed only for the
corresponding quantiles, such as just the max and min for a setting of 2,
unless the bubble is too small. If not manually specified, the default value is set
to TRUE
for a categorical x
variable, and 2 otherwise.
low.color
For a categorical variable and the resulting bubble plot,
or a matrix of these plots, sets a color gradient beginning with this color.
hi.color
For a categorical variables and the resulting bubble plot,
or a matrix of these plots, sets a color gradient ending with this color.
smooth
2-D kernel density plot for two numerical variables. Turned on by
with 2500 or more rows of data.
smooth.points
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.
smooth.trans
Exponent of the function that maps the density scale to the
color scale.
smooth.bins
Number of bins in both directions for the density estimation.
fit
The best fitting 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.
stroke.fit
Color of the best fitting line, if the fit
option
is invoked.
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
numeric value greater than 0 and less than 1, or a vector of levels to plot
multiple ellipses.
stroke.ellipse
Color of the ellipse. If specified, ellipse
is set to
TRUE
.
fill.ellipse
If TRUE
, fill the ellipse with stroke.ellipse
.
Usually specify low opacity in the color specification, as shown in the examples. If
specified, ellipse
is set to TRUE
.
method
Applies to one variable plots. Default is "overplot"
, but can also
provide "stack"
to stack the points or
"jigger"
to scramble the points.
pt.reg
For dot plot, 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.
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-variable scatterplot, superimpose a box plot.
line.chart
If set to TRUE
, points are plotted in the sequential order in which
they occurred in the data table, such as when they are ordered by time of collection.
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.
line.width
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.
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 centerline
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.
show.runs
If TRUE
, display the individual runs in the run analysis. Also sets
line.chart
to TRUE
.
stack
If TRUE
, multiple time plots are stacked on each other with
area
set to TRUE
by default.
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. bin.start
Optional specified starting value of the bins.
bin.width
Optional specified bin width, which can be specified with or without
a bin.start
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.
cumul
Specify a cumulative frequency polygon.
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 theme
function. width
Width of the plot window in inches, defaults to 4.5.
height
Height of the plot window in inches, defaults to 4.5 except for
1-D scatterplots.
pdf.file
Name of the pdf file to if graphics to be redirected to a 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 graphics as defined by and then 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
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
col.lab
for the color of the axis labels
axes
to set the color of the axis values
For one continuous variable, parameters from stripchart