blob: 3f29d25bc04d6ff3aaa0b84162dfc8dab3a3fbfa [file] [log] [blame]
Adrià Vilanova Martínez20de4092023-03-21 17:53:14 +01001library(svglite)
2
3filename = 'Cs_amb_plom'
4scale <- 100 # Scale compared to the Na_smoothest (for the arrows and text)
5
6args = commandArgs(trailingOnly=TRUE)
7
8table <- read.table(paste0('dades/', filename, '.txt'), sep="\t", dec='.', header=TRUE)
9
10# Plot the data
11plotall <- function() {
12 plot(table$ChannelNumber, table$Impulses, type="l", col="#EEEEFF", xlab="Número de canal", ylab="Comptes")
13 lines(table$ChannelNumber, table$ImpulsesSmooth, type="l")
14
15 # Add arrows and text labels to the peaks
16 i <- 1197 + 1
17 arrows(table$ChannelNumber[i], table$ImpulsesSmooth[i] + scale*(3 + 2), table$ChannelNumber[i], table$ImpulsesSmooth[i] + scale*0.2, length = 0.05, code = 1, col = "#799B6F")
18 text(table$ChannelNumber[i], table$ImpulsesSmooth[i] + scale*(5.2 + 2), bquote(atop(gamma["2,0"] * (Ba), 662 ~ keV)), col = "#799B6F", cex = 0.75)
19
20 i <- 365 + 1
21 arrows(table$ChannelNumber[i], table$ImpulsesSmooth[i] + scale*3, table$ChannelNumber[i], table$ImpulsesSmooth[i] + scale*0.2, length = 0.05, code = 1, col = "#799B6F")
22 text(table$ChannelNumber[i], table$ImpulsesSmooth[i] + scale*5.2, bquote(atop(BS ~ gamma["2,0"] * (Ba), 184 ~ keV)), col = "#799B6F", cex = 0.75)
23
24 i <- 150 + 1
25 arrows(table$ChannelNumber[i], table$ImpulsesSmooth[i] + scale*13, table$ChannelNumber[i], table$ImpulsesSmooth[i] + scale*0.2, length = 0.05, code = 1, col = "#F9627D")
26 text(table$ChannelNumber[i], table$ImpulsesSmooth[i] + scale*15.2, bquote(atop("Raigs X", atop("Canal 150", 61 ~ keV))), col = "#F9627D", cex = 0.75)
27}
28
29pdf(paste0('output/', filename, '.pdf'), width = 6, height = 5)
30plotall()
31dev.off()
32
33if (length(args) < 1 || args[1] != "preview") {
34 svg(paste0('output/', filename, '.svg'), width = 6, height = 5)
35 plotall()
36 dev.off()
37}