# Create a temporary directory and write mock spectra files
tmp_dir <- tempdir()
write.csv(data.frame(Energy = 0:30, Counts = rpois(31, lambda = 100)),
file.path(tmp_dir, "spec1.csv"), row.names = FALSE)
write.csv(data.frame(Energy = 0:30, Counts = rpois(31, lambda = 120)),
file.path(tmp_dir, "spec2.csv"), row.names = FALSE)
# Plot the mock spectra using various configuration options
plotSpectra(
folder = tmp_dir,
file_type = "csv",
sep = ",",
normalization = "min-max",
x_config = c(0, 30, 5),
x_reverse = FALSE,
y_trans = "linear",
x_label = expression(Energy~(keV)),
y_label = expression(Counts/1000~s),
line_size = 0.7,
palette = c("black","red"),
plot_mode = "overlapped",
display_names = TRUE,
vertical_lines = c(10, 20),
shaded_ROIs = list(c(12, 14), c(18, 22)),
output_format = "png",
output_folder = tmp_dir
)
Run the code above in your browser using DataLab