R/plot.R
plot_zband.Rd
Utility functions for adding growth standard bands to rbokeh/lattice/ggplot2 plots
ly_zband(fig, x, z = -3:0, color = "green", alpha = 0.15, x_units = c("days", "months", "years")) panel.zband(x, z = -3:0, color = "green", alpha = 0.25) geom_zband(obj, x, z = -3:0, color = "green", alpha = 0.25)
fig | rbokeh figure to add z bands to |
---|---|
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 |
x_units | units of age x-axis (days, months, or years) |
obj | ggplot2 object to add z bands to |
# NOT RUN { library(rbokeh) cpp$haz <- who_value2zscore(x = agedays, y = lencm, sex = sex, data = cpp) figure() %>% ly_zband(cpp$agedays) %>% ly_points(jitter(agedays), haz, data = cpp, color = "black") library(lattice) xyplot(haz ~ jitter(agedays), data = cpp, panel = function(x, y, ...) { panel.zband(x) panel.xyplot(x, y, ...) }, col = "black", alpha = 0.5 ) library(ggplot2) p <- ggplot(data = cpp, aes(x = jitter(agedays), y = haz)) geom_zband(p, x = seq(0, 2600, by = 10)) + geom_point() # }