Open dylanbeaudette opened 5 years ago
This will also require an overhaul of panel.depth_function
: there is some lattice magic that needs to be sorted out relative to setting the plot settings. For example, loading the tactile
package causes the alpha
argument to not be interpreted properly.
The solution for now is to load via ::
.
library(aqp)
library(lattice)
## I don't know why, but loading the tactile library messes things up...
s <- lapply(1:100, random_profile, n_prop = 2, method = 'LPP', SPC = TRUE)
s <- combine(s)
site(s)$group <- factor(sample(c('A', 'B'), size = length(s), replace = TRUE))
table(s$group)
a <- slab(s, ~ p1 + p2)
## works
xyplot(
top ~ p.q50 | variable, data = a,
lower = a$p.q25, upper = a$p.q75,
sync.colors = TRUE,
alpha = 0.5,
cf = a$contributing_fraction,
xlab = 'Median Bounded by IQR',
ylab = 'Depth (cm)',
ylim = c(125,-5), layout = c(2,1),
scales = list(x = list(relation = 'free')),
par.settings = tactile::tactile.theme(superpose.line=list(lwd=2)),
panel = panel.depth_function,
prepanel = prepanel.depth_function,
strip = strip.custom(bg = grey(0.85)),
auto.key = list(columns = 2, lines = TRUE, points = FALSE)
)
## works
a <- slab(s, group ~ p1 + p2)
tps <- tactile::tactile.theme(superpose.line=list(lwd=2))
xyplot(
top ~ p.q50 | variable, data = a,
groups = group,
lower = a$p.q25, upper = a$p.q75,
sync.colors = TRUE,
alpha = 0.2,
cf = a$contributing_fraction,
xlab = 'Median Bounded by IQR',
ylab = 'Depth (cm)',
ylim = c(125,-5), layout = c(2,1),
scales = list(x = list(relation = 'free')),
par.settings = tps,
panel = panel.depth_function,
prepanel = prepanel.depth_function,
strip = strip.custom(bg = grey(0.85)),
auto.key = list(columns = 2, lines = TRUE, points = FALSE)
)
The current approach to plotting the output from
slab()
requires considerable work, vialattice
orggplot2
. For example:There are several places where the source object (
g.slab
) is referenced; leaving plenty of opportunity of mistakes upon copy/paste from a manual page.One possible solution: a bare-bones plotting method (
lattice
orggplot2
, maybe two functions?) for the standardized output fromslab()
. Arguments set the y-variable of interest, optional paneling groups, and optional groups symbolized via colors. Additional arguments set upper/lower width via column names, contributing fraction annotation, and adjustments to transparency and syncing of colors. The basic plot object is then modified viaupdate()
. There must be a similar strategy forggplot2
graphics.Maybe something like this.