R Reference Card Page 3

ADVERTISEMENT

matplot(x,y) bivariate plot of the first column of x vs. the first one of y,
mtext(text, side=3, line=0, ...) adds text given by text in
lty controls the type of lines, can be an integer or string (1: "solid",
the second one of x vs. the second one of y, etc.
the margin specified by side (see axis() below); line specifies the
2: "dashed", 3: "dotted", 4: "dotdash", 5: "longdash", 6:
fourfoldplot(x) visualizes, with quarters of circles, the association be-
line from the plotting area
"twodash", or a string of up to eight characters (between "0" and
tween two dichotomous variables for different populations (x must
segments(x0, y0, x1, y1) draws lines from points (x0,y0) to points
"9") which specifies alternatively the length, in points or pixels, of
be an array with dim=c(2, 2, k), or a matrix with dim=c(2, 2) if
(x1,y1)
the drawn elements and the blanks, for example lty="44" will have
k
1)
arrows(x0, y0, x1, y1, angle= 30, code=2) id. with arrows
the same effect than lty=2
assocplot(x) Cohen–Friendly graph showing the deviations from inde-
at points (x0,y0) if code=2, at points (x1,y1) if code=1, or both if
lwd a numeric which controls the width of lines, default 1
pendence of rows and columns in a two dimensional contingency ta-
code=3; angle controls the angle from the shaft of the arrow to the
mar a vector of 4 numeric values which control the space between the axes
ble
edge of the arrow head
and the border of the graph of the form c(bottom, left, top,
mosaicplot(x) ‘mosaic’ graph of the residuals from a log-linear regres-
abline(a,b) draws a line of slope b and intercept a
right), the default values are c(5.1, 4.1, 4.1, 2.1)
sion of a contingency table
abline(h=y) draws a horizontal line at ordinate y
mfcol a vector of the form c(nr,nc) which partitions the graphic window
pairs(x) if x is a matrix or a data frame, draws all possible bivariate plots
abline(v=x) draws a vertical line at abcissa x
as a matrix of nr lines and nc columns, the plots are then drawn in
between the columns of x
abline(lm.obj) draws the regression line given by lm.obj
columns
plot.ts(x) if x is an object of class "ts", plot of x with respect to time, x
rect(x1, y1, x2, y2) draws a rectangle which left, right, bottom, and
mfrow id. but the plots are drawn by row
may be multivariate but the series must have the same frequency and
top limits are x1, x2, y1, and y2, respectively
pch controls the type of symbol, either an integer between 1 and 25, or any
dates
polygon(x, y) draws a polygon linking the points with coordinates given
single character within ""
ts.plot(x) id. but if x is multivariate the series may have different dates
by x and y
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
a
and must have the same frequency
legend(x, y, legend) adds the legend at the point (x,y) with the sym-
16
17
18
19
20
21
22
23
24
25
*
.
X
X
a
?
?
*
qqnorm(x) quantiles of x with respect to the values expected under a nor-
bols given by legend
ps an integer which controls the size in points of texts and symbols
mal law
title() adds a title and optionally a sub-title
pty a character which specifies the type of the plotting region, "s": square,
qqplot(x, y) quantiles of y with respect to the quantiles of x
axis(side, vect) adds an axis at the bottom (side=1), on the left (2),
"m": maximal
contour(x, y, z) contour plot (data are interpolated to draw the
at the top (3), or on the right (4); vect (optional) gives the abcissa (or
tck a value which specifies the length of tick-marks on the axes as a fraction
curves), x and y must be vectors and z must be a matrix so that
ordinates) where tick-marks are drawn
of the smallest of the width or height of the plot; if tck=1 a grid is
dim(z)=c(length(x), length(y)) (x and y may be omitted)
rug(x) draws the data x on the x-axis as small vertical lines
drawn
filled.contour(x, y, z) id. but the areas between the contours are
locator(n, type="n", ...) returns the coordinates (x y) after the
tcl a value which specifies the length of tick-marks on the axes as a fraction
coloured, and a legend of the colours is drawn as well
user has clicked n times on the plot with the mouse; also draws sym-
of the height of a line of text (by default tcl=-0.5)
image(x, y, z) id. but with colours (actual data are plotted)
bols (type="p") or lines (type="l") with respect to optional graphic
xaxt if xaxt="n" the x-axis is set but not drawn (useful in conjonction with
persp(x, y, z) id. but in perspective (actual data are plotted)
parameters (...); by default nothing is drawn (type="n")
axis(side=1, ...))
stars(x) if x is a matrix or a data frame, draws a graph with segments or a
yaxt if yaxt="n" the y-axis is set but not drawn (useful in conjonction with
Graphical parameters
star where each row of x is represented by a star and the columns are
axis(side=2, ...))
These can be set globally with par(...); many can be passed as parameters
the lengths of the segments
to plotting commands.
symbols(x, y, ...) draws, at the coordinates given by x and y, sym-
adj controls text justification (0 left-justified, 0.5 centred, 1 right-justified)
bols (circles, squares, rectangles, stars, thermometres or “boxplots”)
bg specifies the colour of the background (ex. : bg="red", bg="blue", . . .
Lattice (Trellis) graphics
which sizes, colours . . . are specified by supplementary arguments
the list of the 657 available colours is displayed with colors())
termplot(mod.obj) plot of the (partial) effects of a regression model
xyplot(y˜x) bivariate plots (with many functionalities)
bty controls the type of box drawn around the plot, allowed values are: "o",
(mod.obj)
barchart(y˜x) histogram of the values of y with respect to those of x
"l", "7", "c", "u" ou "]" (the box looks like the corresponding char-
The following parameters are common to many plotting functions:
dotplot(y˜x) Cleveland dot plot (stacked plots line-by-line and column-
acter); if bty="n" the box is not drawn
add=FALSE if TRUE superposes the plot on the previous one (if it exists)
by-column)
cex a value controlling the size of texts and symbols with respect to the de-
axes=TRUE if FALSE does not draw the axes and the box
densityplot(˜x) density functions plot
fault; the following parameters have the same control for numbers on
type="p" specifies the type of plot, "p": points, "l": lines, "b": points
histogram(˜x) histogram of the frequencies of x
the axes, cex.axis, the axis labels, cex.lab, the title, cex.main,
connected by lines, "o": id. but the lines are over the points, "h":
bwplot(y˜x) “box-and-whiskers” plot
and the sub-title, cex.sub
vertical lines, "s": steps, the data are represented by the top of the
qqmath(˜x) quantiles of x with respect to the values expected under a the-
col controls the color of symbols and lines; use color names: "red", "blue"
vertical lines, "S": id. but the data are represented by the bottom of
oretical distribution
see colors() or as "#RRGGBB"; see rgb(), hsv(), gray(), and
the vertical lines
stripplot(y˜x) single dimension plot, x must be numeric, y may be a
rainbow(); as for cex there are: col.axis, col.lab, col.main,
xlim=, ylim= specifies the lower and upper limits of the axes, for exam-
factor
col.sub
ple with xlim=c(1, 10) or xlim=range(x)
qq(y˜x) quantiles to compare two distributions, x must be numeric, y may
font an integer which controls the style of text (1: normal, 2: italics, 3:
xlab=, ylab= annotates the axes, must be variables of mode character
be numeric, character, or factor but must have two ‘levels’
bold, 4: bold italics); as for cex there are: font.axis, font.lab,
main= main title, must be a variable of mode character
splom(˜x) matrix of bivariate plots
font.main, font.sub
sub= sub-title (written in a smaller font)
parallel(˜x) parallel coordinates plot
las an integer which controls the orientation of the axis labels (0: parallel to
Low-level plotting commands
levelplot(z˜x * y|g1 * g2) coloured plot of the values of z at the coor-
the axes, 1: horizontal, 2: perpendicular to the axes, 3: vertical)
dinates given by x and y (x, y and z are all of the same length)
points(x, y) adds points (the option type= can be used)
wireframe(z˜x * y|g1 * g2) 3d surface plot
lines(x, y) id. but with lines
cloud(z˜x * y|g1 * g2) 3d scatter plot
text(x, y, labels, ...) adds text given by labels at coordi-
nates (x,y); a typical use is: plot(x, y, type="n"); text(x, y,
names)

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go
Page of 4