rp.plot4d {rpanel} | R Documentation |
This function plots two covariates coloured by a response variable and animates this by a third covariate. In particular, it is useful for plotting spatiotemporal data.
rp.plot4d(x, z, y, model, col.palette, col.breaks, col.labels, hscale = 1, vscale = hscale, panel = TRUE, x1lab, x2lab, zlab, ylab, background.plot = NULL, foreground.plot = NULL, z.window = "normal", z.window.pars = c(min(z), sd(z)/5), coords = rep(NA, 2), radius = 0.05, location.plot = TRUE, retain.location.plot = FALSE, eqscplot = FALSE, location.plot.type = "histogram") rp.spacetime(space, time, y, model, col.palette, col.breaks, col.labels, hscale = 1, vscale = hscale, panel = TRUE, x1lab, x2lab, zlab, ylab, background.plot = NULL, foreground.plot = NULL, time.window = "normal", time.window.pars = c(min(time), sd(time)/5), coords = rep(NA, 2), radius = 0.05, location.plot = TRUE, retain.location.plot = FALSE, eqscplot = TRUE, location.plot.type = "histogram")
x, space |
a two column matrix of covariates, in particular spatial locations. |
z, time |
a vector of values, such as times, over which the scatterplot will be animated. |
y |
a vector of response values which will be used to colour the plotted points. |
model |
a list with components |
col.palette, col.breaks, col.labels |
the colour palette used to colour the points, the break points on the scale which define the range associated with the each colour and the labels associated with the break points. If |
hscale, vscale |
scaling parameters for the size of the plot when |
panel |
a logical value determining whether an interactive control panel is provided. |
x1lab,x2lab,zlab,ylab |
the axis labels of the variables |
background.plot,foreground.plot |
function to add further graphical material, such as a map, onto the background or foreground of the plot. |
z.window,time.window |
a character string which determines whether the window in |
z.window.pars,time.window.pars |
a vector of length two which sets intial values for the location and width of the |
coords |
a vector of length two which defines the location of the window in the |
radius |
the radius of the window in the |
location.plot |
a logical value which determines whether the mouse can be used to interact with the |
retain.location.plot |
a logical value which determines the intial state of the checkbox determining whether a plot of |
eqscplot |
a logical value which determines whether the |
location.plot.type |
a character variable controlling whether a histogram or a density estimate (using the lattice package) is produced when |
The colour black should be avoided when using a normal window shape for z
. This is because
hsv shading is used to indicate increasing distance from the current z
location and black has an hsv representation with s component 0, which cannot therefore be reduced further.
Nothing is returned.
rpanel: Simple interactive controls for R functions using the tcltk package. Journal of Statistical Software, 17, issue 9.
## Not run: # The quakes data with(quakes, { rp.plot4d(cbind(long, lat), depth) rp.plot4d(cbind(long, lat), depth, mag) }) # SO2 over Europe with(SO2, { location <- cbind(longitude, latitude) if (require(mgcv) & require(maps)) { location1 <- location[,1] location2 <- location[,2] model <- gam(logSO2 ~ s(location1, location2, year)) loc1 <- seq(min(location1), max(location1), length = 30) loc2 <- seq(min(location2), max(location2), length = 30) yr <- seq(min(year), max(year), length = 30) newdata <- expand.grid(loc1, loc2, yr) names(newdata) <- c("location1", "location2", "year") model <- predict(model, newdata) model <- list(x = cbind(loc1, loc2), z = yr, y = array(model, dim = rep(30, 3))) mapxy <- map('world', plot = FALSE, xlim = range(longitude), ylim = range(latitude)) rp.plot4d(location, year, logSO2, model, col.palette = rev(heat.colors(20)), foreground.plot = function() map(mapxy, add = TRUE)) } else rp.plot4d(location, year, logSO2, col.palette = rev(heat.colors(20))) }) # Dissolved Oxygen in the River Clyde with(Clyde, { rp.plot4d(cbind(Doy, DO), Station, location.plot = FALSE) rp.plot4d(cbind(Station, DO), Doy, location.plot = FALSE) # Highlight the data before and after a sewage treatment plant update in 1985 ind <- Year >= 80 & Year <= 89 & !(Year == 85) year <- Year[ind] + Doy[ind] / 365 station <- Station[ind] doy <- Doy[ind] do <- DO[ind] group <- factor(c("before 1985", "after 1985")[1 + as.numeric(year < 85)]) rp.plot4d(cbind(doy, do), station, group, col.palette = c("red", "green"), location.plot = FALSE) }) ## End(Not run)