Hi Mackay and anybody (a) Is it possible to select randomly (let say five grids) and plot? (b) Is it possible to plot five nearest grid in one figure? The original question and improved codes:
#I am ploting gridded time series data. I would like the actual lat #and lon value appear on the graph-if possible inside the graph as #numbers. If there is also more elegant ways to plot the graphs I #>will appreciate more suggestions. ################################# library(ggplot2) library(lattice) month <- c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") month <- factor(month, levels = month.abb) data <- as.data.frame(expand.grid(lon=seq(4,5, 1), lat=seq(-3,-2,1), year=seq(2010, 2012,1), month=month)) n=nrow(data) data$prec <- rgamma(n, 2, 0.25) data$year <- factor(data$year) data$lon <- factor(data$lon) data$lat <- factor(data$lat) ndata <- data[order(data$lon, data$lat),] fix(ndata) max <- max(ndata$prec, na.rm=TRUE) min <- min(ndata$prec, na.rm=TRUE) #Plot the graph and save as pdf by Mackay suggestion pdf("H:/file.pdf") library(latticeExtra) useOuterStrips( xyplot(prec~month|year*paste(lat,lon), data=ndata, as.table = T, type = c("l", "l","p"), ylim=c(min, max), layout=c(1,4)) ) dev.off()#The actual data have more than 5 thousand data points, Just want to plot a few #selected randomly. Also, if I can put 5 data points (nearest grids) in one graph #will be more helpful. Peter Maclean Department of Economics UDSM [[alternative HTML version deleted]] ______________________________________________ R-help@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.