R/plot.R
plot_zband.Rd
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)
range on x axis that should be covered by bands
z-scores at which to draw bands (only need to specify on one side of zero)
color to use for bands
transparency of the bands
ggplot2 object to add z bands to
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
)
}