I am probably missing something quite obvious, but any help would be
appreciated. I am continually getting people misreading the lattice plots
because they are expecting the strip (with the factor names in them) to be
below the graph. Is there anyway of achieving this.
Secondly, from a more personal note I find the grid formed by the axes to be
a bit overpowering and would like to make it a little less bold by changing
it to a grey of some kind. I can't see that the scales options have anythig
in their that I could use. I can change the label colours and tick marks,
but then I draw a blank.
While I'm on a role, I find that quite often I have to resort to the at and
label sections of the scales function to get my tickmarks looking OK. This
seems to be when am producing line graphs with one of the scales being a
date (POSIXct). What is not clear to me is if all POSIXct variables are the
same. The xyplot doco indicates that the at co-ordinates should be native
co-ordinates. Can anyone point me to where in the voluminous documentation
one looks to understand what this means. I have found that on some occasions
the co-ordinates are in seconds (as the documentation on POSIXct states, but
this afternoon I found that the values seemed to be in years. Which wasn't a
problem other than I wish I could understand what was actually happening.
For the "years" example, when the data is originally imported the
years came
in as integers.
str(rbd)
`data.frame': 541 obs. of 6 variables:
$ Year : int 1993 1994 1995 1996 1997 1998 1999 2000 2001 1993 ...
$ Hosp : Factor w/ 75 levels "ALBANY HOSP..",..: 23 23 23 23
23 23
23 23 23 28 ...
$ Beddays : int 2431 2507 2201 2985 2702 2461 2535 2970 3271 1246 ...
$ HD : Factor w/ 21 levels "Avon
HD.","Bunb..",..: 10 10 10 10 10
10 10 10 10 10 ...
$ HR : Factor w/ 6 levels "Goldfields-..",..: 3 3 3 3 3 3 3
3 3 3
...
$ HospCode: int 127 127 127 127 127 127 127 127 127 128 ...
Thinking that I needed a date I promptly put
rbd$Year <- as.POSIXct(ISOdate(rbd$Year,6,30))
then onwards and forwards
for (h in levels(rbd$HR)){
HRData <- subset(rbd,HR==h)
HRData$CommnDesc <- HRData$CommnDesc[,drop=T]
temp <-c((FormatLabels(levels(HRData$CommnDesc)[1],20)))
for (j in 2:length(levels(HRData$CommnDesc))){
temp <- c(temp,FormatLabels(levels(HRData$CommnDesc)[j],20))
}
levels(HRData$CommnDesc) <- temp
p1 <- bwplot(Beddays~Year |CommnDesc,HRData,
panel = "panel.linejoin",
horizontal=F,bty="n",
as.table=T,
par.strip.text=list(lines=3.5,cex=0.8,style=1),
main=paste(h,"Inpatient Beddays"),
scales=list(x=list(cex=0.8,rot=90,
at=c(2,6,9),
labels=c("94","98","01"),col="navy"))
)
print(p1)
savePlot(file=paste(OutputPath,"Inpatient beddays -(lattice) by
region",h,"
",j,sep=""),type="wmf")
}
Of course there are a few things in here that are probably not the right way
to do things, but I tend to be more interested in the output, rather than
whether or not my programming is up to speed. But it has been a little bug
bear of mine about dropping factors when subsetting the data. I've noticed
subset options as I've been going through assorted bits and pieces, but
there never seems to be enough time to follow up.
This is in striking contrast to a previous attempt (most of the code however
is at home not here), but the functions that I worked out for the at and
label functions were
ProcLab <- function(DateData,breakNum){
maxplot <- round(as.numeric(max(DateData)),digits=0)
minplot <- round(as.numeric(min(DateData)),digits=0)
maxplotnum<- round(((maxplot-minplot)/86400)+1,digits=0)
jumpnum <- (maxplotnum/((breakNum)-1))*.98
lablist <- seq(min(DateData),max(DateData),jumpnum*86400)
}
ProcAt <- function(DateData,breakNum){
maxplot <- round(as.numeric(max(DateData)),digits=0)
minplot <- round(as.numeric(min(DateData)),digits=0)
maxplotnum<- round(((maxplot-minplot)/86400)+1,digits=0)
jumpnum <- (maxplotnum/((breakNum)-1))*.98
atlist <- seq(0,maxplotnum,jumpnum)
}
The kludges were in because without them the whole thing fell over,
presumeably because I would needed to have set the limits as well.
_________________________________________________
Tom Mulholland
Senior Policy Officer
WA Country Health Service
189 Royal St, East Perth, WA, 6004
Tel: (08) 9222 4062
e-mail: Tom.Mulholland@health.wa.gov.au
<mailto:Tom.Mulholland@health.wa.gov.au>
The contents of this e-mail transmission are confidential and may be
protected by professional privilege. The contents are intended only for the
named recipients of this e-mail. If you are not the intended recipient, you
are hereby notified that any use, reproduction, disclosure or distribution
of the information contained in this e-mail is prohibited. Please notify the
sender immediately.
[[alternate HTML version deleted]]
On Wednesday 04 June 2003 04:26, Mulholland, Tom wrote:> I am probably missing something quite obvious, but any help would be > appreciated. I am continually getting people misreading the lattice plots > because they are expecting the strip (with the factor names in them) to be > below the graph. Is there anyway of achieving this.No. (At least none that is easy.)> Secondly, from a more personal note I find the grid formed by the axes to > be a bit overpowering and would like to make it a little less bold by > changing it to a grey of some kind. I can't see that the scales options > have anythig in their that I could use. I can change the label colours and > tick marks, but then I draw a blank.It's not very clear to me what you want. If you want to change the colors, that should be doable. What exactly is the problem ? Do you want something more ?> While I'm on a role, I find that quite often I have to resort to the at and > label sections of the scales function to get my tickmarks looking OK. This > seems to be when am producing line graphs with one of the scales being a > date (POSIXct). What is not clear to me is if all POSIXct variables are the > same. The xyplot doco indicates that the at co-ordinates should be native > co-ordinates. Can anyone point me to where in the voluminous documentation > one looks to understand what this means. I have found that on some > occasions the co-ordinates are in seconds (as the documentation on POSIXct > states, but this afternoon I found that the values seemed to be in years. > Which wasn't a problem other than I wish I could understand what was > actually happening.AFAIK, all POSIXct variables should be the 'same', as you say, being the number of seconds since the epoch. They have a particular class, but otherwise they are no different from numeric variables. Older versions of lattice treated these as numeric (which usually were very very large values), and hence put horrible labels. Recent versions try to do something decent when they identify POSIXct variables, but they are not very good at it. So you _will_ need to adjust them by hand most of the time. Hopefully things would improve in the future. I'm not familiar enough with these things to understand your year problem, though. Deepayan
> From: Deepayan Sarkar [mailto:deepayan at stat.wisc.edu] > > On Wednesday 04 June 2003 04:26, Mulholland, Tom wrote: > > I am probably missing something quite obvious, but any help would be > > appreciated. I am continually getting people misreading the > lattice plots > > because they are expecting the strip (with the factor names > in them) to be > > below the graph. Is there anyway of achieving this. > > No. (At least none that is easy.)A possibly easier solution is to introduce gaps from row to row, thus leaving no confusion as to which panel the strip is associated with. My impression is that gaps can be added at least between columns. Not sure about rows. Andy ------------------------------------------------------------------------------ Notice: This e-mail message, together with any attachments, cont... {{dropped}}
On Wednesday 04 June 2003 13:48, Liaw, Andy wrote:> > From: Deepayan Sarkar [mailto:deepayan at stat.wisc.edu] > > > > On Wednesday 04 June 2003 04:26, Mulholland, Tom wrote: > > > I am probably missing something quite obvious, but any help would be > > > appreciated. I am continually getting people misreading the > > lattice plots > > > because they are expecting the strip (with the factor names > > in them) to be > > > below the graph. Is there anyway of achieving this. > > > > No. (At least none that is easy.) > > A possibly easier solution is to introduce gaps from row to row, thus > leaving no confusion as to which panel the strip is associated with. My > impression is that gaps can be added at least between columns. Not sure > about rows.Yes, that sounds like a good idea. Both columns and rows are possible, with between = list(x = 1, y = 1) etc Deepayan
I am not using panel.grid directly. It appears to use the reference.line component of the lattice.theme. Since I have tried changing all obvious comonents in the lattice.theme (including reference.line) I assume I am correct in this assertion. I probably used the wrong word, but I wasn't sure what else to call it. It is the grid around each plot and strip. It dominates the trellis ...(that's what I should have called it). How do you change the colour of the trellis? -----Original Message----- From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk] Sent: Wednesday, 4 June 2003 6:26 PM What grid? You put it there, and you can change its colour. It comes from calling panel.grid, and arg(panel.grid) will hint to you how to change this.