Utility functions for adding growth standard bands to ggplot2/lattice plots

panel.zband(x, z = -3:0, color = "green", alpha = 0.25)

geom_zband(obj, x, z = -3:0, color = "green", alpha = 0.25)

Arguments

x

range on x axis that should be covered by bands

z

z-scores at which to draw bands (only need to specify on one side of zero)

color

color to use for bands

alpha

transparency of the bands

obj

ggplot2 object to add z bands to

Examples


if (FALSE) {
library(ggplot2)
p <- ggplot(data = cpp, aes(x = jitter(agedays), y = haz))
geom_zband(p, x = seq(0, 2600, by = 10)) +
  geom_point()

library(lattice)
xyplot(haz ~ jitter(agedays), data = cpp,
  panel = function(x, y, ...) {
    panel.zband(x)
    panel.xyplot(x, y, ...)
  },
  col = "black", alpha = 0.5
)
}