blob: 4bd301300ddffa307db038d53097d6eda27cabda [file] [log] [blame]
Adrià Vilanova Martínez20de4092023-03-21 17:53:14 +01001library(svglite)
2
3filename = 'Na_smoothest'
4
5args = commandArgs(trailingOnly=TRUE)
6
7table <- read.table(paste0('dades/', filename, '.txt'), sep="\t", dec='.', header=TRUE)
8
9# Plot the data
10plotall <- 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
24indexes <- c()
25labels <- c()
26peaks <- data.frame(indexes, labels)
27
28pdf(paste0('output/', filename, '.pdf'), width = 6, height = 5)
29plotall()
30dev.off()
31
32if (length(args) < 1 || args[1] != "preview") {
33 svg(paste0('output/', filename, '.svg'), width = 6, height = 5)
34 plotall()
35 dev.off()
36}