plot.yourcast {YourCast} | R Documentation |
Creates graphics from yourcast output for each geographical unit and prints to the device window or a .pdf file in the specified directory
## S3 method for class 'yourcast': plot(x, dpath=getwd(), dvlabel=NULL, family="agetime", time.insamp.obs=TRUE, time.insamp.predict=TRUE, age.insamp.predict=TRUE, threedim.insamp.predict=TRUE, age.xlab=NULL, age.ylab=NULL, time.xlab=NULL, time.ylab=NULL, threedim.xlab=NULL, threedim.ylab=NULL, threedim.zlab=NULL, screen=list(z=-40, x=-60, y=0), print="device", ...)
x |
yourcast output object |
dpath |
String. Directory where ‘.pdf’ outputs are
saved. Defaults to working directory if not specified. Will be
ignored if print="device" . Default: getwd() |
dvlabel |
String. Description of dependent variable that will be
used as the main title for the plots. Default: NULL |
family |
String. Specifies type of plot generated by the
function. time creates a time series plot where each age
cohort is plotted separately on the device. age creates a
plot of forecasts on age where data from each each year is
plotted separately. agetime creates a side-by-side
presentation of the age and time plots. Finally,
threedim creates a three-dimensional plot of the
information in the ‘age’ and ‘time’
plots. Default: agetime |
time.insamp.obs |
Boolean. For time and ‘time’ plots in
agetime plots, specifies whether observed values should be
plotted within the range of years with observations for the
dependent variable. Default: TRUE |
time.insamp.predict |
Boolean. For time and ‘time’
plots in agetime plots, specifies whether
predicted values should be plotted within the range of years with
observations for the dependent variable. For time plots,
the default is to print both predicted and observed values; this
option merely removes predicted values from this range if set to
FALSE . Default: TRUE |
age.insamp.predict |
Boolean. For age plots and the
‘age’ plots of agetime plots, specifies whether
predicted values should be plotted within the range of years with
observations for the dependent variable. If set to
FALSE , predicted values are replaced by observed values in
this range. Default: TRUE |
threedim.insamp.predict |
Boolean. For threedim plots,
specifies whether predicted values should be plotted within the
range of years with observations for the dependent variable. If set to
FALSE , predicted values are replaced by observed values in
this range. Default: TRUE |
age.xlab |
String. The label for the ‘x’ axis of age plots
and the ‘age’ plot of agetime plots. Will be ignored
if ‘age’ plot not created. Default: "Age" |
age.ylab |
String. The label for the ‘y’ axis of age plots
and the ‘age’ plot of agetime plots. Will be ignored
if ‘age’ plot not created. Default: "Forecasts" |
time.xlab |
String. The label for the ‘x’ axis of time
plots and the ‘time’ plot of agetime plots. Will be
ignored if ‘time’ plot not created. Default: "Time" |
time.ylab |
String. The label for the ‘y’ axis of time
plots and the ‘time’ plot of agetime plots. Will be
ignored if ‘time’ plot not created. Default: "Data and
Forecasts" |
threedim.xlab |
String. The label for the ‘x’ axis of
threedim plots. Will be ignored if ‘threedim’ plot
not created. Default: "Year" |
threedim.ylab |
String. The label for the ‘y’ axis of
threedim plots. Will be ignored if ‘threedim’ plot
not created. Default: "Age" |
threedim.zlab |
String. The label for the ‘z’ axis of
threedim plots. Will be ignored if ‘threedim’ plot
not created. Default: "Forecasts" |
screen |
List. List with three elements ‘x’, ‘y’,
and ‘z’ that rotate the viewing angle for three dimensional
plots. Argument ignored for all other plot types.
Default: list(z=-40, x=-60, y=0) |
print |
Boolean. Specifies whether graphical output should be
displayed sequentially on a device window (device ) or saved
directly to a ‘.pdf’ file in the dpath .
Default: "device" |
... |
Arguments to be passed to par() for the purpose of setting
graphical parameters for the plotting functions. See
help(par) for more details. |
Prints sequentially to the device or saves ‘.pdf’ files
with the requested plot for each geographic unit in the sample. If
requested, ‘.pdf’ files will be saved in a specified directory or
the working directory. Three-dimensional plots are created with the
wireframe
function from the lattice
library. For space
considerations, axes are labeled with the numerical versions of the
‘age’ and ‘time’ vectors regardless of whether
A.names
and T.names
are supplied to
yourcast
.
Plots are titled with the dvlabel
and the G.names
dataframe if it was supplied to yourcast
in the
dataobj
. For example if dvlabel="Respiratory
Infections"
and the geographic identifier for that region is matched
with "Belize"
, the plot will be titled “Respiratory Infections,
Belize”. One or both labels will be utilized by the function if available.
Axis labels can be changed with the appropriate xlab
,
ylab
, and zlab
arguments.
It is important to note that plot.yourcast
will only work if
all cross sections within the same geographic unit are of the same
dimensions. If, for example, a cross section for one age group has
fewer yearly observations than another from the same group, these
missing years must be filled in with NA
, even if they occur in
the beginning of the sample period. This does not hold across
geographic units, however.
Finally, plot.yourcast
handles agetime
plots differently
than the other families by opening a new device window for each new
plot. This is done so that the size of the device can be controlled to
keep the side-by-side plots from appearing distorted when launched. This
convenience makes it impossible to place multiple plots on the same
device, however. Users seeking to create 1x2, 2x2, 3x2, etc., plot
layouts for the purposes of comparison are advised to use the separate
age
and time
plot families and print each plot indivudally
to the device.
Below is some example code for a 2x2 plot layout with, in effect, two ‘agetime’ plots:
par(mfrow=c(2,2)) plot(y.out1,family="age") plot(y.out1,family="time") plot(y.out2,family="age") plot(y.out2,family="time")
Device windows with requested plots or ‘.pdf’ files saved
in the dpath
.
Jon Bischof jbischof@fas.harvard.edu
http://gking.harvard.edu/yourcast
yourcast
function and documentation
(help(yourcast)
)