### example data
set.seed(1)
z <- matrix(rnorm(40), 20, 2) # persons
w <- matrix(rnorm(30), 15, 2) # items
alpha <- rnorm(nrow(z)) # person alpha
beta <- rnorm(nrow(w)) # item beta
### 1) minimal, fixed colors & shapes
intermap2d(z, w)
### 2) minimal, fixed shapes for persons and labels for items
intermap2d(
z, w,
show_w_shapes = FALSE, show_w_labels = TRUE
)
### 3) Grouped colors + sized shapes, formal legend title
intermap2d(
z, w,
person_group = rep(c("Cohort A", "Cohort B"), length.out = nrow(z)),
item_group = rep(c("Domain X", "Domain Y", "Domain Z"), length.out = nrow(w)),
alpha = alpha, beta = beta,
z_shape_size_scale = TRUE, z_shape_size_range = c(2, 6),
w_shape_size_scale = TRUE, w_shape_size_range = c(2, 8),
show_z_shapes = TRUE, show_w_shapes = FALSE,
show_w_labels = TRUE, legend_title = "Cohort / Domain"
)
### 4) Gradient for persons only (darker = higher alpha), labels scaled by alpha
intermap2d(
z, w,
alpha = alpha,
z_shape_color_gradient = TRUE, # z by gradient
w_shape_color = "red", # w fixed color
z_label_size_scale = TRUE, # label size proportional to alpha
show_w_shapes = FALSE,
show_w_labels = TRUE,
# shape_color_gradient_low = "grey80", shape_color_gradient_high = "navy",
legend_title = expression(alpha[p])
)
### 5) Gradient for both alpha (persons) and beta (items), shared legend
intermap2d(
z, w,
alpha = alpha, beta = beta,
z_shape_color_gradient = TRUE, w_shape_color_gradient = TRUE,
shape_color_gradient_low = "grey80", shape_color_gradient_high = "navy",
z_shape_size_scale = TRUE, w_shape_size_scale = TRUE,
show_z_shapes = TRUE, show_w_shapes = TRUE,
show_z_labels = FALSE, show_w_labels = FALSE,
legend_title = "Intensity (alpha persons, beta items)"
)
### 6) Explicit per-observation colors (vectors) + label-only
z_cols <- ifelse(alpha > 0, "#1f77b4", "#AEC7E8")
w_cols <- ifelse(beta > 0, "#d62728", "#FF9896")
intermap2d(
z, w,
person_colors = z_cols, item_colors = w_cols,
show_z_shapes = FALSE, show_w_shapes = FALSE,
show_z_labels = TRUE, show_w_labels = TRUE
)
### 7) Opacity scaling + fixed shape sizes
intermap2d(
z, w,
alpha = alpha, beta = beta,
z_shape_opacity_scale = TRUE, z_shape_opacity_range = c(0.2, 1.0),
w_shape_opacity_scale = TRUE, w_shape_opacity_range = c(0.4, 1.0),
z_shape_color = "black", w_shape_color = "orange3",
z_shape_size = 3, w_shape_size = 3.5, # fixed sizes (no size scaling)
show_z_shapes = TRUE, show_w_shapes = TRUE
)
### 8) Label-only scaling; shape sizes fixed; custom legend title for groups
intermap2d(
z, w,
person_group = rep(c("High", "Low"), length.out = nrow(z)),
alpha = alpha, beta = beta,
z_label_size_scale = TRUE, w_label_size_scale = TRUE,
z_label_size_range = c(3, 7), w_label_size_range = c(3, 7),
show_z_labels = TRUE, show_w_labels = FALSE,
show_z_shapes = FALSE, show_w_shapes = TRUE,
legend_title = "Performance Group"
)
### 9) Stretch coordinates + axis ticks + symmetric limits
intermap2d(
z, w,
gamma = 1.5,
show_ticks = TRUE,
xlim_range = c(-4, 4), ylim_range = c(-4, 4),
person_group = rep(c("Train","Test"), length.out = nrow(z)),
legend_title = "Set Membership"
)
Run the code above in your browser using DataLab