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 pdf("H:/file.pdf") xyplot(prec~month|year+lon+lat, data=ndata, type = c("l", "l","p"), ylim=c(min, max), layout=c(1,4)) dev.off() ############################## #I want to remove the lat and lon rows and put the numbers inside the graph ############################################################################ Peter Maclean Department of Economics UDSM [[alternative HTML version deleted]]
Hi Peter As for more suggestions 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)) ) have a look at ?strip.custom and ?strip.default as well as ?useOuterStrips for customizing the strips and ?panel.text for within the panel. HTH Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email: home: mackay at northnet.com.au At 18:13 20/02/2013, you wrote:>Content-Type: text/plain >Content-Disposition: inline >Content-length: 1370 > >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 >pdf("H:/file.pdf") > >xyplot(prec~month|year+lon+lat, data=ndata, > type = c("l", "l","p"), ylim=c(min, max), > layout=c(1,4)) >dev.off() > > >############################## >#I want to remove the lat and lon rows and put the numbers inside the graph >############################################################################ > >Peter Maclean >Department of Economics >UDSM > [[alternative HTML version deleted]] > > >______________________________________________ >R-help at 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.
I'm trying to work the lattice xYplot function to plot confidence intervals for two groups on the same plot. The problem is that it automatically labels the groups (1 and 2) on the plot itself, and the labels get obscured by the CI lines and make it look bad. This is my code: xYplot(Cbind(Mean,L95,U95) ~ jitter(Time), type='b', data=A,main="Bouts Vs. Time",col=c('black', 'gray'), groups=Group,title="Bouts",xlab="Time", ylab="Bouts", method="bars", lwd=3, ylim=c(0,30)) A is the data, with columns Time, Group, Mean, L95, U95. L95 and U95 are the lower and upper confidence interval estimates. Group is either 1 or 2, each measured at the same number of time points. The goal is simply to take the labels off of the plot itself. Then I can use an auto.key to put the labels on the side. Please help! -Ben [[alternative HTML version deleted]]
Possibly Parallel Threads
- Help xyplot
- HELP DATA CLIPPING AND DATA OVERLAY ON A MAP
- lattice: double y - problem changing axis color after doubleYScale
- How to do a meta-analysis plot
- Editing the variables attributes section in the netCDF header of netCDF files created using the package ncdf.