Kurapati, Ravichandra (Ravichandra)
2008-May-21 04:54 UTC
[Rd] need some help in plotting xy graph
Hi Dataframe fdf contains bin rate overlay 1 1 90 Assign First/cc _from_SN_53 RNC_20_to_SN_50 RNC_21_Success Rate 2 2 93 Assign First/cc _from_SN_53 RNC_20_to_SN_50 RNC_21_Success Rate 3 1 90 Assign First/cc _from_SN_50 RNC_21_to_SN_53 RNC_20_Success Rate 4 2 94 Assign First/cc _from_SN_50 RNC_21_to_SN_53 RNC_20_Success Rate time 1 (04/01/08 16:02:30) 2 (04/01/08 16:07:30) 3 (04/01/08 16:02:30) 4 (04/01/08 16:07:30) And then I write the following lines of code to plot a xygraph on a pdf file n <- length(unique(fdf$time)) x <-sort(unique(fdf$time)) y<-UTCsecs2chron(x) xscales <- computeTimeScales(y) yscales<-NULL scales<-c(xscales,yscales) ylab<-"session transfer rate" xlab<-"time" lgnd.txt<-levels(fdf$overlay) celnet.trellis.device(device="pdf", file="ravi_st.pdf", width=10,height = 10) main<-"this is the first report" formd="rate ~ as.numeric(time)" print( xyplot(formula(formd), data = fdf, groups = overlay, type = "b", as.table = TRUE, cex=0.20, #subset = ok, commented to show breaks in graph main = main, xlab = "Time", ylab = ylab, scales = scales, key = simpleKey(text = lgnd.txt, cex = 3/4, points = FALSE, lines = TRUE), page = function(n) annotate(opts$ann), sub = "", layout = c(1,1) ) ) "computeTimeScales" <- function(z, rot=0) ## z is a chron object {browser() ## how many days do the data span? n.days <- ceiling(diff(range(z, na.rm = TRUE))) ## compute x ticks, pretty labels x <- as.numeric(z) r <- range(x, na.rm = TRUE) at.x <- seq(from = r[1], to = r[2], length = 7) two_digits <- function(x){ x <- paste("0", x, sep="") substring(x,nchar(x)-1) } ## heuristics: use hh:mm when range of data falls within one day, ## otherwise use MM-DD hh:mm. at.z <- chron(at.x) hh <- paste(two_digits(hours(at.z)), two_digits(minutes(at.z)), sep=":") if(0){ ## hh:ss # this is commented as for more than one day from/to time no date was printed at.lbls <- hh } else { ## MM-DD\nhh:ss m <- month.day.year(at.z) dd <- paste(two_digits(m$month), two_digits(m$day), sep="-") at.lbls <- paste(dd, hh, sep="\n") } list(x=list(at = at.x, rot=rot, labels = at.lbls)) } "celnet.theme" <- function() { celnet.theme <- canonical.theme("pdf", color = TRUE) if(tolower(.Device) =="png") celnet.theme$background$col <- "white" else canonical.theme("pdf", color = TRUE) celnet.theme$background$col <- "transparent" celnet.theme } "celnet.trellis.device" <- function(device, file, width = NULL, height = NULL,...) { ## analogous to trellis.device() -- this is just tailored to Celnet if(is.null(width)) width <- 8 if(is.null(height)) height <- 6 if(tolower(device)=="png"){ if(missing(width)) width <- 72 * width if(missing(height)) height <- 72 * height } if(tolower(device)=="x11") trellis.device(device, width=width, height=height, theme=celnet.theme()) if(tolower(device)=="ps" || tolower(device)=="postscript") trellis.device("postscript", file=file, color = TRUE, width=width, height=height, theme=celnet.theme()) else trellis.device(device, file=file, width=width, height=height, theme=celnet.theme()) } "annotate" <- function(str, ...) ## print a metadata message at the top-bottom of current trellis display { else if(n==1){ x <- 0.95 hjust <- "right" } else if(n==2){ x <- c(0.05, 0.95) hjust <- c("left", "right") } else if(n==3){ x <- c(0.05, 0.50, 0.95) hjust <- c("left", "center", "right") } x <- unit(x, "npc") y <- unit(1.5, "lines") ## at 0.5, 1.5, ... lines for(i in seq(along = x)){ grid.text(label = str[i], x = x[i], y = y, just = c(hjust[i], "bottom"), ...) } invisible(str) } n <- length(str) ## one line per string if(n==0) return(invisible(str)) } But I did nt get any desired o/p on a file ravi_st.pdf Desired o/p is Rate ~ as.numeric(time) Group=overlay Can any one tell how can I get the desired o/p [[alternative HTML version deleted]]
On 5/20/08, Kurapati, Ravichandra (Ravichandra) <ravichandra.kurapati at alcatel-lucent.com> wrote:> > > Hi > > > > Dataframe fdf contains > > > > bin rate overlay > > 1 1 90 Assign First/cc _from_SN_53 RNC_20_to_SN_50 RNC_21_Success > Rate > > 2 2 93 Assign First/cc _from_SN_53 RNC_20_to_SN_50 RNC_21_Success > Rate > > 3 1 90 Assign First/cc _from_SN_50 RNC_21_to_SN_53 RNC_20_Success > Rate > > 4 2 94 Assign First/cc _from_SN_50 RNC_21_to_SN_53 RNC_20_Success > Rate > > time > > 1 (04/01/08 16:02:30) > > 2 (04/01/08 16:07:30) > > 3 (04/01/08 16:02:30) > > 4 (04/01/08 16:07:30)It would be more work to read in your data than I have time for. Could you post it in a more convenient format? (The output of dput(fdf) should be fine.) -Deepayan
1) If you need some help, *PLEASE* use the R-help mailing list. 2) Sending your e-mail more than once (you sent it 3 times!) to the same mailing list of hundreds of subscribers is considered very impolite. Martin Maechler, ETH Zurich, R-devel List manager>>>>> "KR\" == Kurapati, Ravichandra \(Ravichandra\) <ravichandra.kurapati at alcatel-lucent.com> >>>>> on Wed, 21 May 2008 10:24:48 +0530 writes:KR\> Hi KR\> Dataframe fdf contains KR\> bin rate overlay KR\> 1 1 90 Assign First/cc _from_SN_53 RNC_20_to_SN_50 RNC_21_Success KR\> Rate KR\> 2 2 93 Assign First/cc _from_SN_53 RNC_20_to_SN_50 RNC_21_Success KR\> Rate KR\> 3 1 90 Assign First/cc _from_SN_50 RNC_21_to_SN_53 RNC_20_Success KR\> Rate KR\> 4 2 94 Assign First/cc _from_SN_50 RNC_21_to_SN_53 RNC_20_Success KR\> Rate KR\> time KR\> 1 (04/01/08 16:02:30) KR\> 2 (04/01/08 16:07:30) KR\> 3 (04/01/08 16:02:30) KR\> 4 (04/01/08 16:07:30) KR\> And then I write the following lines of code to plot a xygraph on a pdf KR\> file KR\> n <- length(unique(fdf$time)) KR\> x <-sort(unique(fdf$time)) KR\> y<-UTCsecs2chron(x) KR\> xscales <- computeTimeScales(y) KR\> yscales<-NULL KR\> scales<-c(xscales,yscales) KR\> ylab<-"session transfer rate" KR\> xlab<-"time" KR\> lgnd.txt<-levels(fdf$overlay) KR\> celnet.trellis.device(device="pdf", file="ravi_st.pdf", width=10,height KR\> = 10) KR\> main<-"this is the first report" KR\> formd="rate ~ as.numeric(time)" KR\> print( KR\> xyplot(formula(formd), KR\> data = fdf, groups = overlay, KR\> type = "b", as.table = TRUE, cex=0.20, KR\> #subset = ok, commented to show breaks in graph KR\> main = main, xlab = "Time", ylab = ylab, KR\> scales = scales, KR\> key = simpleKey(text = lgnd.txt, cex = 3/4, KR\> points = FALSE, lines = TRUE), KR\> page = function(n) annotate(opts$ann), KR\> sub = "", KR\> layout = c(1,1) KR\> ) KR\> ) KR\> "computeTimeScales" <- KR\> function(z, rot=0) ## z is a chron object KR\> {browser() KR\> ## how many days do the data span? KR\> n.days <- ceiling(diff(range(z, na.rm = TRUE))) KR\> ## compute x ticks, pretty labels KR\> x <- as.numeric(z) KR\> r <- range(x, na.rm = TRUE) KR\> at.x <- seq(from = r[1], to = r[2], length = 7) KR\> two_digits <- function(x){ KR\> x <- paste("0", x, sep="") KR\> substring(x,nchar(x)-1) KR\> } KR\> ## heuristics: use hh:mm when range of data falls within one day, KR\> ## otherwise use MM-DD hh:mm. KR\> at.z <- chron(at.x) KR\> hh <- paste(two_digits(hours(at.z)), two_digits(minutes(at.z)), KR\> sep=":") KR\> if(0){ ## hh:ss # this is commented as for more than one day KR\> from/to time no date was printed KR\> at.lbls <- hh KR\> } KR\> else { ## MM-DD\nhh:ss KR\> m <- month.day.year(at.z) KR\> dd <- paste(two_digits(m$month), two_digits(m$day), sep="-") KR\> at.lbls <- paste(dd, hh, sep="\n") KR\> } KR\> list(x=list(at = at.x, rot=rot, labels = at.lbls)) KR\> } KR\> "celnet.theme" <- KR\> function() KR\> { KR\> celnet.theme <- canonical.theme("pdf", color = TRUE) KR\> if(tolower(.Device) =="png") KR\> celnet.theme$background$col <- "white" KR\> else KR\> canonical.theme("pdf", color = TRUE) KR\> celnet.theme$background$col <- "transparent" KR\> celnet.theme KR\> } KR\> "celnet.trellis.device" <- KR\> function(device, file, width = NULL, height = NULL,...) KR\> { KR\> ## analogous to trellis.device() -- this is just tailored to Celnet KR\> if(is.null(width)) KR\> width <- 8 KR\> if(is.null(height)) KR\> height <- 6 KR\> if(tolower(device)=="png"){ KR\> if(missing(width)) width <- 72 * width KR\> if(missing(height)) height <- 72 * height KR\> } KR\> if(tolower(device)=="x11") KR\> trellis.device(device, width=width, height=height, KR\> theme=celnet.theme()) KR\> if(tolower(device)=="ps" || tolower(device)=="postscript") KR\> trellis.device("postscript", file=file, color = TRUE, KR\> width=width, height=height, theme=celnet.theme()) KR\> else KR\> trellis.device(device, file=file, KR\> width=width, height=height, theme=celnet.theme()) KR\> } KR\> "annotate" <- KR\> function(str, ...) KR\> ## print a metadata message at the top-bottom of current trellis KR\> display KR\> { else if(n==1){ KR\> x <- 0.95 KR\> hjust <- "right" KR\> } else if(n==2){ KR\> x <- c(0.05, 0.95) KR\> hjust <- c("left", "right") KR\> } else if(n==3){ KR\> x <- c(0.05, 0.50, 0.95) KR\> hjust <- c("left", "center", "right") KR\> } KR\> x <- unit(x, "npc") KR\> y <- unit(1.5, "lines") ## at 0.5, 1.5, ... lines KR\> for(i in seq(along = x)){ KR\> grid.text(label = str[i], KR\> x = x[i], y = y, just = c(hjust[i], "bottom"), ...) KR\> } KR\> invisible(str) KR\> } KR\> n <- length(str) ## one line per string KR\> if(n==0) KR\> return(invisible(str)) KR\> } KR\> But I did nt get any desired o/p on a file ravi_st.pdf KR\> Desired o/p is KR\> Rate ~ as.numeric(time) KR\> Group=overlay KR\> Can any one tell how can I get the desired o/p KR\> [[alternative HTML version deleted]] KR\> ______________________________________________ KR\> R-devel at r-project.org mailing list KR\> https://stat.ethz.ch/mailman/listinfo/r-devel