print.TwoTrellisColumns | R Documentation |
Print two conformable trellis plots in adjacent columns with user control of widths. Left y tick-labels and left.strip are removed from the right-hand plot.
as.TwoTrellisColumns5(left, ## left is the left trellis object
right, ## right is the right trellis object
## Both left and right must have identical
## settings for number and size of vertical panels,
## left-axis labels, number of lines in main, sub, legend.
...,
pw=c(.3, .30, .01, .30, .09),
px=list(
LL=c(0, pwc[1]),
LP=pwc[1:2],
ML=pwc[2:3],
RP=pwc[3:4],
RL=pwc[4:5]),
pwc=cumsum(pw),
strip.left=TRUE,
y.tck=c(0,0)
)
## S3 method for class 'TwoTrellisColumns5'
print(x, px=attr(x, "px"), ...)
leftLabels.trellis(x)
rightLabels.trellis(x)
panelOnly.trellis(x, strip.left=FALSE, y.tck=0)
mainSubLegend.trellis(x)
emptyRightAxis(x)
left , right |
Conformable |
x |
|
px |
These are used |
pw , pwc |
|
strip.left |
See |
y.tck |
A vector of one or two numeric values.
This will be used as the |
... |
Other arguments are ignored. |
as.TwoTrellisColumns5
constructs a "TwoTrellisColumns5"
object, which is a list of five trellis objects named "LL", "LP",
"ML", "RP", "RL"
. LL
is the left labels from the left
input object. LP
is the panels from the left
input object.
ML
is the middle labels from the left
object; these are
the main
title, sub
title, and legend
. RP
is the panels from the right
input object. RL
is the
right labels from the right
input object.
print.TwoTrellisColumns5
is a print method for a
"TwoTrellisColumns5"
object. It takes left-to-right positioning
information from the "px"
attribute of its argument x
or
from an input argument. The numbers are used as the "x"
information for the position
argument to the print.trellis
method.
emptyLeftAxis,
leftLabels.trellis,
rightLabels.trellis,
panelOnly.trellis,
mainSubLegend.trellis,
emptyLeftStrip,
emptyRightAxis
are functions which blank out the various components of the trellis
argument and retains their vertical spacing.
A "TwoTrellisColumns5"
object, consisting of a list
containing the constructed left, middle, and right trellis objects,
and an attribute containing the px
value.
Richard M. Heiberger <rmh@temple.edu>
likert
for the details on the motivating example.
## These are based on the Professional Challenges example in ?likert
data(ProfChal)
levels(ProfChal$Subtable)[6] <- "Prof Recog" ## reduce length of label
## initial ordering of Question factor
PCC <- likert(Question ~ . | Subtable, ProfChal, ylab=NULL,
rightAxis=TRUE,
layout=c(1,6),
strip=FALSE,
strip.left=strip.custom(bg="gray97"),
par.strip.text=list(cex=.7),
scales=list(y=list(relation="free")),
main="Is your job professionally challenging?")
## initial ordering of Question factor
PCP <- likert(Question ~ . | Subtable, ProfChal, ylab=NULL,
as.percent=TRUE,
layout=c(1,6),
strip=FALSE,
strip.left=strip.custom(bg="gray97"),
par.strip.text=list(cex=.7),
scales=list(y=list(relation="free")),
main="Is your job professionally challenging?")
## Not run:
## default equal widths of the two panels
as.TwoTrellisColumns5(PCP, PCC) ## 11in x 7in
## make left panel twice as wide as right panel
as.TwoTrellisColumns5(PCP, PCC, pw=c(.3, .4, .01, .2, .09)) ## 11in x 7in
## -------------------- ## sum to 1.00
## make left panel twice as wide as right panel, and control position of main and legend
as.TwoTrellisColumns5(PCP, PCC, ## 11in x 7in
px=list(
LL=c(.00, .30),
LP=c(.30, .70),
ML=c(.60, .61), ## arbitrary,
## visually center the labels and legend
RP=c(.71, .91),
RL=c(.91, 1.00)))
## End(Not run)
## Size that works in default 7x7 window. 7x7 is not recommended for
## this example because most of the space is used for labeling and not
## much for the panels containing the data. Use the px values for the
## 11x7 illustrated above in the dontrun section.
as.TwoTrellisColumns5(PCP, PCC, ## 7in x 7in
px=list(
LL=c(.00, .50),
LP=c(.50, .70),
ML=c(.50, .51), ## arbitrary,
## visually center the labels and legend
RP=c(.71, .87),
RL=c(.87, 1.00)))
## Ordering the rows by the lengths of the positive bars and also
## put percents and counts on the same plot.
## The easiest way is to use the LikertPercentCountColumns function:
LikertPercentCountColumns(Question ~ . | Subtable, ProfChal,
layout=c(1,6), scales=list(y=list(relation="free")),
ylab=NULL, between=list(y=0),
strip.left=strip.custom(bg="gray97"), strip=FALSE,
par.strip.text=list(cex=.7),
positive.order=TRUE,
main="Is your job professionally challenging?")
## Not run:
## Ordering the rows by the lengths of the positive bars and also
## putting percents and counts on the same plot requires coordination.
## The easiest way is to order the original tables of counts by the
## order of the percent plot.
percentPlot <- likert(Question ~ . | Subtable, ProfChal,
as.percent=TRUE,
layout=c(1,6), scales=list(y=list(relation="free")),
ylab=NULL, between=list(y=0),
strip.left=strip.custom(bg="gray97"), strip=FALSE,
par.strip.text=list(cex=.7),
positive.order=TRUE,
main="Is your job professionally challenging?")
## percentPlot
pct.order <- percentPlot$y.limits[[1]]
ProfChal2 <- ProfChal
ProfChal2$Question <- factor(ProfChal2$Question, levels=rev(pct.order))
countPlot <- likert(Question ~ . | Subtable, ProfChal2,
layout=c(1,6),
rightAxis=TRUE,
scales=list(y=list(relation="free"),
x=list(at=c(0, 250, 500))),
ylab=NULL, between=list(y=0),
strip.left=strip.custom(bg="gray97"), strip=FALSE,
par.strip.text=list(cex=.7),
main="Is your job professionally challenging?")
## countPlot
levels(ProfChal$Subtable)[6] <-
"Attitude\ntoward\nProfessional\nRecognition" ## Restore original label
## Size that works in default 7x7 window. 7x7 is not recommended for
## this example because most of the space is used for labeling and not
## much for the panels containing the data. Use the px values for the
## 11x7 illustrated above in the dontrun section.
as.TwoTrellisColumns5(percentPlot, countPlot, ## 7in x 7in
px=list(
LL=c(.00, .50),
LP=c(.50, .70),
ML=c(.50, .51), ## arbitrary,
## visually center the labels and legend
RP=c(.71, .87),
RL=c(.87, 1.00)))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.