search for: prepanel

Displaying 20 results from an estimated 35 matches for "prepanel".

2006 Oct 12
adding error bars to lattice plots
...annot figure out where they should go. Deepayan's original code follows, with additions from me for factor, grouping and by variables. (Note that I could use xYplot (Dotplot), but I need my response variable on the vertical axis.) Any suggestions would be greatly appreciated. Thanks, Dan <- function(x, y, lx, ux, subscripts, ...) { x <- as.numeric(x) lx <- as.numeric(lx[subscripts]) ux <- as.numeric(ux[subscripts]) list(xlim = range(x, ux, lx, finite = TRUE)) } <- function(x, y, lx, ux, subscripts, pch = 16, ...) {...
2006 Oct 11
panel-dependent distribution in qqmath
...bout having 'distribution' change with panel.number? I've tried set.seed(1) mydata <- data.frame(ind = factor(rep(2:4, each = 100))) mydata$val <- rt(300, df=rep(2:4, each = 100)) plot<-qqmath(~ val | ind, layout=c(3,1), data = mydata, prepanel = function(x, distribution, ...) { mydist<-function(p) qt(p, df = panel.number() + 1) prepanel.qqmathline(x, distribution=mydist,...) }, panel = function(x, distribution, ...) { mydist<-function(p) qt(p, df = panel.numb...
2010 May 25
segplot (latticeExtra)
...or dotplot in another thread, the following looked promising, but gives empty panels: ---<--------------------cut here---------------start------------------->--- segplot(reorder(factor(county), rate.male) ~ LCL95.male + UCL95.male | year, data=uscr.w, scales="free", prepanel=function(x, y, z, ...) { zz <- z[, drop=TRUE] list(sort(unique(zz))) }, panel=function(x, y, z, ...) { zz <- z[, drop=TRUE] panel.segplot(x, y, zz, ...) }) ---<--------------------cut here---------------end------------...
2005 Feb 16
panel/prepanel for polar plots ala xYplot
...mostly I have been reverse engineering code and experimenting to figure out how things work. 2) What is the best way to generate "axis" and labels for them? Currently my radplot is a wrapper for xyplot that (a) turns off the axes and labels, and (b) calls xyplot with panel.radplot, prepanel.radplot, and radplot.superpose replacing the obvious things. I am generating the "axes" (concentric circles and peripheral labels) in panel.radplot, but this means that they are redrawn for each group when there is superposition. Furthermore, there seems to be some jittering, so bes...
2008 Jul 08
aggregate() function and na.rm = TRUE
All, I've been using aggregate() to compute means and standard deviations at time/treatment combinations for a longitudinal dataset, using na.rm = TRUE for missing data. This was working fine before, but now when I re-run some old code it isn't. I've backtracked my steps and can't seem to find out why it was working before but not now. In any event, below is a reproducible
2013 Feb 15
lattice 3x3 plot: force common y-limits accross rows and align x-axes
....c(). This almost works but in the merged plot I cannot decrease column spacing to be small enough. Also, the output of trellis.c() would not work with useOuterStrips() which I really like. My code is in TRY ONE below. Another way to create the plot is specify y-limits for each panel with custom prepanel and panel functions. For each panel, the data-frame for the panel row is isolated, subjects in the data-frame for the current row are ordered by counts, panel y-limits are set to the re-ordered levels, y-data for each panel is releveled, and data plotted with standard panel.dotplot(). This somewh...
2010 Apr 09
lattice background grid
Hi, I wonder if anyone knows how to control color and darkness of the background grid generated by ' type = c("g", "p") ' in a lattice plot (e.g., in xyplot). The documentation does not seem to offer a way to change them. Thanks a lot! Wen
2017 Dec 14
change in behavior of c.trellis
> library(latticeExtra) Loading required package: lattice Loading required package: RColorBrewer > t11 <- xyplot(1 ~ 1) > t11 > c(t11, t11) Warning message: In formals(fun) : argument is not a function > version _ platform x86_64-w64-mingw32 arch x86_64 os mingw32 system x86_64, mingw32 status Patched major 3
2003 Sep 17
Date on x-axis of xyplot
...3rd Qu.:12.000 Graham : 54 Max. :29.000 Kerry : 54 (Other) :216 > And all seems well. But xyplot continues to use day number on the x-axis. My plots are created by print(xyplot(pct ~ begdate | names, pch=2, cex=.2, prepanel = function(x, y) prepanel.loess(x, y, span = 1), main="2004 Democratic Primary Race", xlab = "Date of Survey", ylab = "Percent Support", panel = function(x, y) { panel.grid(h=-1, v= -1) panel.xyplot(x, y, pch=1,col=2,cex=.7) panel.loess...
2003 Sep 04
Putting regression lines on SPLOM
Sorry Folks, I'm sure I could suss out the answer myself but I need it soon ... ! 1. Given a set of 4 variables X,Y,Z,W in a dataframe DF, I make a scatter-plot matrix using splom(DF). 2. I do all regressions of U on V using lm(U~V), where U and V are all 12 different ordered pairs from X,Y,Z,W. 3. Now I would like to superpose the regression lines from (2) onto the corresponding
2007 Feb 24
barchart (lattice) with text labels
I would like to place the value for each bar in barchart (lattice) at the top of each bar. Something like the following code produces. library(lattice) mypanelfunc <- function(x, y, ...) { panel.barchart(x, y, ...) panel.text(x, y, labels=as.character(round(x,2)), ...) } myprepanelfunc <- function(x, y, ...) list(xlim=c(0, max(x)+.1)) mydata <- expand.grid(a=factor(1:5), b=factor(1:3), c=factor(1:2)) mydata$x <- runif(nrow(mydata)) barchart(a~x|b, mydata, groups=c, panel=mypanelfunc, prepanel=myprepanelfunc, adj=c(-0.1,0.5)) However, I cannot figure out how to shi...
2010 Jan 14
lattice dotplot with missing levels in factor variable
...ed to follow the "Lattice ..." book and used dotplot(lvl~rsp|cat,data=xx,type=c("h","p"), panel=function(x,y,...){y1 <- reorder(y,x) y1 <- y1[,drop=TRUE] panel.dotplot(x,y1,...)}, prepanel=function(x,y){y1 <- reorder(y,x) y1 <- y1[,drop=TRUE] return(list(ylim=levels(y1)))}, layout=c(1,2)) However, the resulting has incorrect y-labels: Desired Plot Achieved Plot Panel B: Panel B:...
2008 Jun 16
Error bars within xyplot, panel = function(x,y, ....)
...ose.line = list(lty = c(1,5), col=c('black', 'black') ) ) ) ## this code uses the functions provided by Deepayan Sarkar to include the ## error bars for the same data: xyplot(Y ~ Hr, groups=DRUG, data=data, ly = data$lower, uy = data$upper, prepanel =, panel = panel.superpose, panel.groups =, type="b", auto.key = list(space = "top", text = c( "D","P"), points = FALSE, lines = TRUE, columns=2), par.settings = list(superpose.line = list(lty = c(1,5), co...
2011 Aug 04
error bar plot with log scale in lattice
...all, I'm trying to modify the code to a log scale for y-axis from the post However, the error bar did not change accordingly. The following is the code I used based on the singer.ucl data. Thanks in advance! <- function(x, y, ly, uy, subscripts, ...) { y <- as.numeric(y) ly <- as.numeric(ly[subscripts]) uy <- as.numeric(uy[subscripts]) list(ylim = range(y, uy, ly, finite = TRUE),y=list(log=10)) } <- function(x, y, ly, uy, subscripts, pch = 16, col.line = '...
2010 Jul 12
Xyplot or Tin-R problem?
I ran the following script from xyplot Examples using Tin-R on Windows and saw no plot produced. EE <- equal.count(ethanol$E, number=9, overlap=1/4) xyplot(NOx ~ C | EE, data=ethanol, prepanel = function(x,y) prepanel.loess(x, y, span=1), xlab="Compression Ratio", ylab="NOx (micrograms/J)", panel = function(x,y) { panel.grid()(h = -1, v=2) panel.xyplot(x,y) panel.loess(x,y, span=1) }, aspect = "xy") The Rgui sh...
2004 Aug 10
date axes and formats in levelplot
Hi all (and particularly Deepayan), A while back Deepayan helped me with the query in the text below (thanks again). Specifically it was about changing the way that dates plotted on the axes of lattice plots. While this works using xyplot, everything comes apart when I use levelplot. The axis labels on the date axis are shown as the integer representation of the date (number of seconds since
2007 Jan 23
How to generate 'minor' ticks in lattice (qqmath)
...umy,min=0,max=1) sig=0.05 numsig=length(which(y<sig)) # number of ticks labl=as.character(0.1*tcks-0.1) # label for all ticks labl[seq(2,,2)]="" # delete every second label nums=seq(0,(,( qqmath(y,distribution=qunif, prepanel=NULL, panel=function(x) { panel.abline(c(0,1),lty=2) panel.polygon(c(0,0,numsig/numy,numsig/numy,0),c(0,sig,sig,0,0),lwd=0.75) panel.qqmath(x,distribution=qunif,col=1) }, scales=list( tck=c(1,0), x=list(at=nums,labels=labl), cex=0.8), xlab=pa...
2003 Dec 25
Problem plotting with xyplot
..., 314,14,1.12, 314,15,1.12 ), byrow = T, ncol = 3 )) names(tolerance.pp) <- c('id','age','tolerance') ## this plots out fine xyplot(tolerance~age | factor(id), data=tolerance.pp) ## this produces an error message xyplot(tolerance~age | factor(id), data=tolerance.pp, prepanel = function(x, y) prepanel.loess(x, y), panel = function(x, y){ panel.xyplot(x, y) panel.loess(x, y) }, ylim=c(0, 4), as.table=T) Error message is: >Error in simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE, : > NA/NaN/Inf in foreign function...
2009 May 27
Changing point color/character in qqmath
Having solved this problem, I am posting this so that the next time I search for how to do this I will find an answer... Using qqmath(..., groups=num) creates a separate qq distribution for each group (within a panel). Using the 'col' or 'pch' argument does not (usually) work because panel.qqmath sorts the data (but not 'col' or 'pch') before plotting. Sorting
2006 Oct 02
xyplot Graphic Help
...ample Site",cex=3), ylab=list(label=expression(paste("Particles" >= "0.5 ",mu,"m/ft"^"2")),cex=3), ylim=c(-100,1200), # index.cond=list(c(2,1)), scales=list(x=list(relation="free", cex=2),y=list(cex=2)), prepanel=function(x,y,... ) { # yy <- y[,drop=TRUE] xx <- x[,drop=TRUE] list(xlim=levels(xx), # ylim=levels(yy), xat=sort(unique(as.numeric(xx))) # yat=sort(unique(as.numeric(yy))) ) }, panel=function(x,y,sub...