具有不同行数的格子图
Lattice plot with different count of rows
我想创建一个包含 4 个不同面板的格子图。其中 2 个面板应该是 2 个盒子,另外 2 个面板应该是 3 个盒子。 Lattice 会自动在前 2 个面板中绘制一个空行(见下图)。我怎样才能删除这个空 row/space,以便在前 2 个面板中只显示 line_a 和 line_b?
示例:
library("lattice")
set.seed(123)
N <- 2000
dat_a_b <- data.frame(x = rnorm(N),
lines = c(rep("line_a", N / 2),
rep("line_b", N / 2)),
head1 = rep(c(rep("head1_a", N / 4),
rep("head1_b", N / 4)), 2),
head2 = rep(c(rep("head2_a", N / 8),
rep("head2_b", N / 8)), 4))
dat_c <- data.frame(x = rnorm(N / 2, 5),
lines = rep("line_c", N / 2),
head1 = rep(c(rep("head1_a", N / 8),
rep("head1_b", N / 8)), 2),
head2 = rep("head2_a", N / 2))
dat_all <- rbind(dat_a_b, dat_c)
bwplot(x = lines ~ x | head1 * head2, data = dat_all)
当前图表:
非常感谢!
设置y轴的刻度为"free":
bwplot(x = lines ~ x | head1 * head2, data = dat_all,
scales = list(y = "free"))
我想创建一个包含 4 个不同面板的格子图。其中 2 个面板应该是 2 个盒子,另外 2 个面板应该是 3 个盒子。 Lattice 会自动在前 2 个面板中绘制一个空行(见下图)。我怎样才能删除这个空 row/space,以便在前 2 个面板中只显示 line_a 和 line_b?
示例:
library("lattice")
set.seed(123)
N <- 2000
dat_a_b <- data.frame(x = rnorm(N),
lines = c(rep("line_a", N / 2),
rep("line_b", N / 2)),
head1 = rep(c(rep("head1_a", N / 4),
rep("head1_b", N / 4)), 2),
head2 = rep(c(rep("head2_a", N / 8),
rep("head2_b", N / 8)), 4))
dat_c <- data.frame(x = rnorm(N / 2, 5),
lines = rep("line_c", N / 2),
head1 = rep(c(rep("head1_a", N / 8),
rep("head1_b", N / 8)), 2),
head2 = rep("head2_a", N / 2))
dat_all <- rbind(dat_a_b, dat_c)
bwplot(x = lines ~ x | head1 * head2, data = dat_all)
当前图表:
非常感谢!
设置y轴的刻度为"free":
bwplot(x = lines ~ x | head1 * head2, data = dat_all,
scales = list(y = "free"))