Description Usage Arguments Details Value Author(s) References See Also Examples
A generic layout function for plotting tiled arrangements of graphic styles found in the tile package, including scatterplots, lineplots, dotplots and more specialized formats. Includes fine control of titles, axes, axis transformation, and rugs for all plots.
1 2 3 4 5 6 7 | tile(..., limits = NULL, frame = FALSE, gridlines = list(),
xaxis = list(), yaxis = list(), topaxis = list(), rightaxis = list(),
xaxistitle = list(), yaxistitle = list(), topaxistitle = list(), rightaxistitle = list(),
maintitle = list(), rowtitle = list(), columntitle = list(), plottitle = list(), undertitle = list(),
RxC=NULL, output = list(), width = list(), height = list(),
leeway = 0, draw = FALSE, defaults = list(),
layoutonly = FALSE, titleboxes = FALSE, axisboxes = FALSE, verbose = FALSE)
|
... |
Any number of “traces”, or lists of traces, as supplied by tile graphic
functions such as |
limits |
A vector or matrix giving the limits of the plotting region,
similar to |
frame |
Logical; draw a frame around plots (use a vector to set
for specific plots). Default is |
gridlines |
A list controlling the printing of gridlines in the
plotting regions. Each input may be a scalar (to set the
parameter globally for all plots) or a vector (to set the
parameter plot by plot). Alternatively, for multiplot layouts you
may specify, e.g., separate types for plot 1 by providing
|
xaxis |
A list; controls the plotting and format of the
x-axes. The inputs below are generic, and apply to all plots.
Alternatively, for multiplot layouts you may specify, e.g., separate
labels for plot 1 by providing
|
yaxis |
A list; controls the plotting and format of the y-axes;
see |
topaxis |
A list; controls the plotting and format of the top-axes;
see |
rightaxis |
A list; controls the plotting and format of the right-axes;
see |
xaxistitle |
A list; places titles for the x-axes and
controls their format. These inputs should be scalar if the same
treatment is desired for the titles of different plots, or vector
if different results are desired for each title (
|
yaxistitle |
A list; places titles for the y-axes and controls
their format; see |
topaxistitle |
A list; places titles for the top-axes and controls
their format; see |
rightaxistitle |
A list; places titles for the right-axes and controls
their format; see |
maintitle |
A list; places a single title above the entire graphic and
controls its format. See |
rowtitle |
A list; places titles to the left of each row of
plots and controls their format. See |
columntitle |
A list; places titles above each column of plots and
controls their format. See |
plottitle |
A list; places titles above each plot and
controls their format. See |
undertitle |
A list; places titles below each plot and
controls their format. See |
RxC |
A 2-vector giving the number of rows and columns of the tiling of plots. Default is to place all plots in a single row. |
output |
A list controlling the output device:
|
width |
A list of widths of various plot elements. Modify these to improve the look of spacing of plots and titles, or to expand the width of plotting areas.
|
height |
A list of heights of various plot elements. Modify these to improve the look of spacing of plots and titles, or to change the aspect ratio of plotting areas.
|
leeway |
When finding plot region limits automatically, add a little leeway beyond data limits. Default is 0. |
draw |
Logical indicating whether a copy of the plot should be
plotted to the current screen device, in addition to the device
specified in |
defaults |
List object with default settings for title heights and widths, and other tile parameters. Users will not normally need to changes these settings. |
layoutonly |
Logical. If |
titleboxes |
Logical. Draws boxes around title plotting areas.
Helpful as a diagnostic for poorly behavied layouts; not intended
for final plots. Default is |
axisboxes |
Logical. Draws boxes around axis plotting areas.
Helpful as a diagnostic for poorly behavied layouts; not intended
for final plots. Default is |
verbose |
Logical. If |
With the tile package, you can not only create elegant graphical displays of data, but also of the quantitative implications of fitted regression models. In particular, the package makes it easy to repeat the same graphic in a tiled arrangement (small multiples), and always allows for the inclusion of confidence intervals around any plotted quantity.
A typical script producing a tile graphic follows three steps:
Obtain data to plot. These data may be the underlying variables of interest, or quantities inferred from models. (For this step, you should use your own modeling code, or a package for extracting counterfactual inferences from a model, such as Zelig or simcf.) For example, you may have a set of expected values of a response variable calculated conditional on different hypothetical values of covariates, and may wish to plot those expected values along with their confidence intervals. Or you might have the actual draws from posterior distributions, and decide to leave the summary of those draws by confidence intervals up to graphing function.
Create traces from the data. A trace is a single set of data to be added to the plot, and may be as simple as a text label or a line segment, or as complex as a set of points combined their best fit line and shaded confidence region. All the parameters affecting the construction and appearance of the trace are set using one of the many functions in the tile package. These include several functions for creating primitives (analogous to grid functions):
linesTile | Plot a set of connected line segments |
pointsTile | Plot a set of points |
polygonTile | Plot a shaded region |
polylinesTile | Plot a set of unconnected line segments |
textTile | Plot text labels |
And several functions for constructing complex traces for model or data exploration:
lineplot | Plot lines with confidence intervals, extrapolation warnings |
nightplot | (Experimental) Plot bounded quantites using equal-area lozenges |
riceplot | (Experimental) Plot up to five dimensions to a 2D scatter |
ropeladder | Plot dotplots with confidence intervals, extrapolation warnings, |
and shaded ranges | |
scatter | Plot scatterplots with text and symbol markers, |
fit lines, and confidence intervals | |
This is the point to tweak the look of the plotted data and
annotations—essentially, anything inside the plotted areas of the
tiled plots. (Rugs, which technically lie along the outer borders of plots, also get set up at this stage. To add a rug, create a trace using rugTile
.)
Create the tiled graphic. Finally, give all the traces
as inputs to a single call to tile
. At this point, you can
customize the look of the plotting framework: inputs to tile
let you change the rows and columns of tiled plots; include, scale,
and label ticks for any axes on any plots; add and format titles of
axes, plots, rows of plots, or columns of plots; and add and customize
gridlines and frames around plots. This is also the time to select the graphical device on which to save the graph.
tile follows a draw-at-once philosophy. No drawing takes
place until the user provides all the traces to tile
.
Considering the entire graphic at once, tile
determines how
to allocate space in the graphic to each of the tiled plots, axes,
and titles. Only then are the elements in the graphic drawn, in the
order specified by the layer
of each graphical object. As a
result, it is not easy to modify or annotate an existing graphic
from the R command line. Instead, if you desire to modify a plot,
you should modify the traces used to create the graphic, and re-run
tile
to create the graphic anew.
tile
is mainly called for the side-effect of saving a graphic to
the requested device. However, it does return a list containing all
the user inputs, default settings, and numerous internal values. This
list contains a copy of the entire plot in the slot grob
. To
draw this graphical object to the current device, give the output from tile as
input to tileDraw
.
Christopher Adolph cadolph@uw.edu
Murrell, Paul. (2006) R Graphics. Chapman \& Hall/CRC.
lineplot
, scatter
,
ropeladder
, nightplot
,
riceplot
, rugTile
, linesTile
,
pointsTile
, textTile
,
polylinesTile
, polygonTile
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | # Example 1: A tile layout template
trace1 <- textTile("Plot Area 1", x=500, y=50, plot=1)
trace2 <- textTile("Plot Area 2", top=500, right=50, plot=2)
trace3 <- textTile("Plot Area 3", x=500, y=50, plot=3)
trace4 <- textTile("Plot Area 4", top=500, right=50, plot=4)
trace5 <- textTile("Plot Area 5", x=500, y=50, plot=5)
trace6 <- textTile("Plot Area 6", top=500, right=50, plot=6)
at.x <- c(1,5,10,20,35)
at.y <- c(0,0.2,0.4,0.6,0.8,1)
tc <- tile(trace1,
trace2,
trace3,
trace4,
trace5,
trace6,
# Plotting options
RxC=c(2,3), # Tile 2 rows & 3 columns of plots
gridlines=list(type="xytr"),
limits=c(0.1,1000, # min(x), max(x)
0,100, # min(y), max(y)
0.1,1000, # min(top), max(top)
0,100), # min(right), max(right)
xaxis=list( # User provided tick locations
log1=10,
log3=10,
log5=10
),
xaxistitle=list(labels1="X Axis 1",
labels3="X Axis 3",
labels5="X Axis 5"),
topaxis=list(at=at.x, # User provided tick locations
log1=10,
log3=10,
log5=10
),
topaxistitle=list(labels2="Top Axis 2",
labels4="Top Axis 4",
labels6="Top Axis 6"),
yaxistitle=list(labels1="Y Axis 1",
labels3="Y Axis 3",
labels5="Y Axis 5"),
rightaxistitle=list(labels2="Right Axis 2",
labels4="Right Axis 4",
labels6="Right Axis 6"),
plottitle=list(fontface="bold",
labels=c("Plot Title 1",
"Plot Title 2",
"Plot Title 3",
"Plot Title 4",
"Plot Title 5",
"Plot Title 6")
),
maintitle=list(fontface="bold",
labels=c("Main title")
),
rowtitle=list(labels=c("Row Title 1",
"Row Title 2")
),
columntitle=list(labels=c("Column Title 1",
"Column Title 2",
"Column Title 3")
),
undertitle=list(fontface="italic",
labels=c("Under Title 1",
"Under Title 2",
"Under Title 3",
"Under Title 4",
"Under Title 5",
"Under Title 6")
),
frame=TRUE,
output = list(file="tile2x3layout")
)
# Example 2: Small multiples
# Example 3: A multi-trace layout
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.