| library(tikzDevice) |
| |
| nom <- 'Ra_aire' |
| scale <- 4 |
| |
| table <- read.table(paste0('dades/', nom, '.txt'), sep="\t", dec='.', header=TRUE) |
| |
| # Plot the data |
| plotall <- function() { |
| plot(table$Energy, table$Impulses, type="l", col="#EEEEFF", xlab="Energia (keV)", ylab="Comptes", ylim=c(0, 100)) |
| lines(table$Energy, table$ImpulsesSmooth, type="l") |
| |
| # Add arrows and text labels to the peaks |
| for (j in 1:nrow(peaks)) { |
| i <- peaks[j, 'indexes'] |
| label <- peaks[j, 'labels'] |
| 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") |
| 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) |
| } |
| } |
| |
| # Els valors dins de c(...) són les files del fitxer de dades. |
| # Es resta 2 per trobar els índexs (2 columnes són headers). |
| indexes <- c(207, 327, 645) - 2 |
| labels <- c("\\textsuperscript{210}Po + \\textsuperscript{222}Rn", "\\textsuperscript{218}Po", "\\textsuperscript{214}Po") |
| peaks <- data.frame(indexes, labels) |
| |
| pdf(paste0('output/', nom, '.pdf'), width = 6, height = 5) |
| plotall() |
| dev.off() |
| |
| tikz(paste0('output/', nom, '.tex'), width = 6, height = 5) |
| plotall() |
| dev.off() |