Kurapati, Ravichandra (Ravichandra)
2008-May-20 13:02 UTC
[R] 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 Can any one tell how can I get the desired o/p [[alternative HTML version deleted]]
Kurapati, Ravichandra (Ravichandra)
2008-May-21 04:44 UTC
[R] 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]]
Kurapati, Ravichandra (Ravichandra)
2008-May-21 08:07 UTC
[R] need some help in plotting xy graph
fdf dataframe contains the data as follows "bin" "rate" "overlay" "x" 1 90 "Assign First/cc _from_SN_53 RNC_20_to_SN_50 RNC_21_Success Rate" (04/01/08 16:02:30) 2 93 "Assign First/cc _from_SN_53 RNC_20_to_SN_50 RNC_21_Success Rate" (04/01/08 16:07:30) 1 90 "Assign First/cc _from_SN_50 RNC_21_to_SN_53 RNC_20_Success Rate" (04/01/08 16:02:30) 2 94 "Assign First/cc _from_SN_50 RNC_21_to_SN_53 RNC_20_Success Rate" (04/01/08 16:07:30) I want to plot a xygraph on xaxis-"x" on y-axis-"rate" groups=overlay formd<-"rate ~ as.numeric(x)" groups<-overlay lgnd.txt<-levels(df$overlay) print(xyplot(formula(formd),data = fdf, groups = overlay, type = "b", as.table = TRUE, cex=0.20,main = "this is my first plot", xlab = "Time", ylab = "session transfer",scales = c(xscales,yscales),key = simpleKey(text = lgnd.txt, cex = 3/4,points = FALSE, lines = TRUE), layout = c(1,1))) but I didn't get any o/p so can u tel how can I get the desired xygraph from fdf dataframe -----Original Message----- From: Deepayan Sarkar [mailto:deepayan.sarkar at gmail.com] Sent: Wednesday, May 21, 2008 10:43 AM To: Kurapati, Ravichandra (Ravichandra) Cc: r-devel at r-project.org Subject: Re: [Rd] need some help in plotting xy graph On 5/20/08, Kurapati, Ravichandra (Ravichandra) <ravichandra.kurapati at alcatel-lucent.com> wrote:> > Dataframe df contains > > > > bin rateoverlay> > 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