# Create sample data
set.seed(123)
data <- data.frame(
V1 = rnorm(100), V2 = rnorm(100), V3 = rnorm(100), V4 = rnorm(100), name = 1:100,
antigen = rep(c(0,1), 50), antiserum = rep(c(1,0), 50),
cluster = rep(1:5, each=20), year = rep(2000:2009, each=10)
)
# Create a static plot and save to a temporary file
# This example requires an interactive session and the 'rgl' package.
if (interactive() && requireNamespace("rgl", quietly = TRUE)) {
temp_dir <- tempdir()
# Basic interactive plot (will open a new window)
if(interactive()) {
plot_3d_mapping(data, ndim=4)
}
# Custom configuration for temporal visualization
aesthetic_config <- new_aesthetic_config(
point_size = 5,
point_alpha = 0.8,
gradient_colors = list(
low = "blue",
high = "red"
)
)
layout_config <- new_layout_config(
width = 12,
height = 12,
background_color = "black",
show_axis = TRUE
)
# Create customized static plot and save it
plot_3d_mapping(data, ndim=4,
aesthetic_config = aesthetic_config,
layout_config = layout_config,
interactive = FALSE, output_dir = temp_dir
)
list.files(temp_dir)
unlink(temp_dir, recursive = TRUE)
}
Run the code above in your browser using DataLab