Adrià Vilanova Martínez | 20de409 | 2023-03-21 17:53:14 +0100 | [diff] [blame] | 1 | library(svglite) |
| 2 | |
| 3 | filename = 'Na_smoothest' |
| 4 | |
| 5 | args = commandArgs(trailingOnly=TRUE) |
| 6 | |
| 7 | table <- read.table(paste0('dades/', filename, '.txt'), sep="\t", dec='.', header=TRUE) |
| 8 | |
| 9 | # Plot the data |
| 10 | plotall <- function() { |
| 11 | plot(table$ChannelNumber, table$Impulses, type="l", col="#EEEEFF", xlab="Número de canal", ylab="Comptes") |
| 12 | lines(table$ChannelNumber, table$ImpulsesSmooth, type="l") |
| 13 | |
| 14 | # Add arrows and text labels to the peaks |
| 15 | i <- 934 + 1 |
| 16 | arrows(table$ChannelNumber[i], table$ImpulsesSmooth[i]+3, table$ChannelNumber[i], table$ImpulsesSmooth[i]+0.2, length = 0.05, code = 1, col = "#514E7E") |
| 17 | text(table$ChannelNumber[i], table$ImpulsesSmooth[i]+5.2, bquote(atop(gamma ^ "±" * (Ne), 511 ~ keV)), col = "#514E7E", cex = 0.75) |
| 18 | |
| 19 | i <- 341 + 1 |
| 20 | arrows(table$ChannelNumber[i], table$ImpulsesSmooth[i]+3, table$ChannelNumber[i], table$ImpulsesSmooth[i]+0.2, length = 0.05, code = 1, col = "#799B6F") |
| 21 | text(table$ChannelNumber[i], table$ImpulsesSmooth[i]+5.2, bquote(atop(BS ~ gamma ^ "±" * (Ne), 170 ~ keV)), col = "#799B6F", cex = 0.75) |
| 22 | } |
| 23 | |
| 24 | indexes <- c() |
| 25 | labels <- c() |
| 26 | peaks <- data.frame(indexes, labels) |
| 27 | |
| 28 | pdf(paste0('output/', filename, '.pdf'), width = 6, height = 5) |
| 29 | plotall() |
| 30 | dev.off() |
| 31 | |
| 32 | if (length(args) < 1 || args[1] != "preview") { |
| 33 | svg(paste0('output/', filename, '.svg'), width = 6, height = 5) |
| 34 | plotall() |
| 35 | dev.off() |
| 36 | } |