blob: a9217aaf1f0aa0591186bc596328fc5d65e532ab [file] [log] [blame]
Adrià Vilanova Martínez42b8a892023-03-21 00:18:28 +01001library(tikzDevice)
2
3nom <- 'Ra_aire'
4scale <- 4
5
6table <- read.table(paste0('dades/', nom, '.txt'), sep="\t", dec='.', header=TRUE)
7
8# Plot the data
9plotall <- function() {
10 plot(table$Energy, table$Impulses, type="l", col="#EEEEFF", xlab="Energia (keV)", ylab="Comptes", ylim=c(0, 100))
11 lines(table$Energy, table$ImpulsesSmooth, type="l")
12
13 # Add arrows and text labels to the peaks
14 for (j in 1:nrow(peaks)) {
15 i <- peaks[j, 'indexes']
16 label <- peaks[j, 'labels']
17 arrows(table$Energy[i], table$ImpulsesSmooth[i] + scale*(if (j == 1) 5 else 3), table$Energy[i], table$ImpulsesSmooth[i] + scale*0.1, length = 0.05, code = 1, col = "#514E7E")
18 text(table$Energy[i], table$ImpulsesSmooth[i] + scale*(if (j == 1) 6.6 else 4.6), paste0(table$Energy[i], " keV", "\n", label), col = "#514E7E", cex = 0.75)
19 }
20}
21
22# Els valors dins de c(...) són les files del fitxer de dades.
23# Es resta 2 per trobar els índexs (2 columnes són headers).
24indexes <- c(207, 327, 645) - 2
25labels <- c("\\textsuperscript{210}Po + \\textsuperscript{222}Rn", "\\textsuperscript{218}Po", "\\textsuperscript{214}Po")
26peaks <- data.frame(indexes, labels)
27
28pdf(paste0('output/', nom, '.pdf'), width = 6, height = 5)
29plotall()
30dev.off()
31
32tikz(paste0('output/', nom, '.tex'), width = 6, height = 5)
33plotall()
34dev.off()