My thanks to this mailing list and its members for their great help in the past. I have yet another question per the following code and comments:
# I need individual graphs grouped by "PARLABEL" AND "Event", with "PARLABEL"
# controlling pct and lty, and "Event" controlling col (where Event==1 is green
# and Event==2 is red). This is attempted in the xyplot parameter
# "groups = c(PARLABEL, Event)". Current behavior appears to be that the
# colors are controlled by "PARLABEL" along with the shape and line type. Some
# experimentation with those two parameters (reverse order, one or the other only)
# suggests that the second parameter is ignored.
#
# I have also experimented with panel.superpose, subsetting, and Extended formula
# interface, as appears to be suggested by the "man pages", but to no avail.
#
# Note that I can get the graphics layout I need with ggplot2, but that has its
# own issues with secondary axis and subtitle text placement, formatting, and
# pagination.
#
# Example script below. Datafile included.
depthlimit=c(7,-1)
xlimit=c(0.1,125000)
TransectOrder = c("LLR19", "LLR18", "LLR17")
OffsetOrder = c("T", "U", "V", "Y", "Z",
"A", "B", "C", "D", "E", "F", "G", "H")
# Parse the data for these plots ---------------------------------------------
df <- read.csv(file = "5.04-r02_LTC-SE-SO-Compared.csv")
df$Transect <- factor(df$Transect, levels = TransectOrder)
levels(df$Transect)
df$Offset <- factor(df$Offset, levels = OffsetOrder)
levels(df$Offset)
xyplot((sbd+sed)/2 ~ Result | Offset+Transect, groups = c(PARLABEL, Event),
as.table = TRUE,
drop.unused.levels = FALSE, data = df,
layout = c(13,3), type = "b",
xlim = c(0.01, 122000), ylim = depthlimit,
pch =c(16, 18), cex = c(1, 1), # to be controlled by "PARLABEL"
lty =c("dashed", "solid"), # to be controlled by "PARLABEL"
col = c("green", "red"), # to be controlled by "Event"
scales = list(alternating = 1, x = list(rot = 45, log = TRUE)))
Yours,
Guy Jett, R.G.
Project Geologist
ITSI,? A Gilbane Company
gjett at itsi.com
Lattice xyplot to group by two parameters
2 messages · Guy Jett, Deepayan Sarkar
On Thu, Jun 23, 2011 at 10:15 PM, Guy Jett <GJett at itsi.com> wrote:
My thanks to this mailing list and its members for their great help in the past. ?I have yet another question per the following code and comments: # I need individual graphs grouped by "PARLABEL" AND "Event", with "PARLABEL" # ? controlling pct and lty, and "Event" controlling col (where Event==1 is green # ? and Event==2 is red). This is attempted in the xyplot parameter # ? "groups = c(PARLABEL, Event)". Current behavior appears to be that the # ? colors are controlled by "PARLABEL" along with the shape and line type. ?Some # ? experimentation with those two parameters (reverse order, one or the other only) # ? suggests that the second parameter is ignored.
[Please let me know which part of the documentation suggested anything otherwise, and I will try to fix it.]
# I have also experimented with panel.superpose, subsetting, and Extended formula # ? interface, as appears to be suggested by the "man pages", but to no avail.
Here is an example you should be able to adapt: http://lmdvr.r-forge.r-project.org/figures/figures.html?chapter=09;figure=09_02;theme=stdBW;code=right -Deepayan
# ? Note that I can get the graphics layout I need with ggplot2, but that has its
# ? own issues with secondary axis and subtitle text placement, formatting, and
# ? pagination.
#
# Example script below. ?Datafile included.
?depthlimit=c(7,-1)
?xlimit=c(0.1,125000)
?TransectOrder = c("LLR19", "LLR18", "LLR17")
?OffsetOrder ?= ?c("T", "U", "V", "Y", "Z",
? ? ? ? ? ? ? ? ? ?"A", "B", "C", "D", "E", "F", "G", "H")
# Parse the data for these plots ---------------------------------------------
?df <- read.csv(file = "5.04-r02_LTC-SE-SO-Compared.csv")
?df$Transect <- factor(df$Transect, levels = TransectOrder)
?levels(df$Transect)
?df$Offset <- factor(df$Offset, levels = OffsetOrder)
?levels(df$Offset)
? ?xyplot((sbd+sed)/2 ~ Result | Offset+Transect, groups = c(PARLABEL, Event),
? ? ?as.table = TRUE,
? ? ?drop.unused.levels = FALSE, data = df,
? ? ?layout = c(13,3), type = "b",
? ? ?xlim = c(0.01, 122000), ylim = depthlimit,
? ? ?pch ?=c(16, 18), cex = c(1, 1), # to be controlled by "PARLABEL"
? ? ?lty ?=c("dashed", "solid"), ? ? # to be controlled by "PARLABEL"
? ? ?col = c("green", "red"), ? ? ? ?# to be controlled by "Event"
? ? ?scales = list(alternating = 1, x = list(rot = 45, log = TRUE)))
Yours,
Guy Jett, R.G.
Project Geologist
ITSI,? A Gilbane Company
gjett at itsi.com
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.