blob: 54c0ef4402b64975945b9b42464dc2a016ff009c [file] [log] [blame]
Adrià Vilanova Martínez42b8a892023-03-21 00:18:28 +01001library(tikzDevice)
2
3nom <- 'Pic_Am'
4scale <- 4
5
6plotbg <- function(table, number) {
7 col1 = ""
8 col2 = ""
9 if (number == 0) {
10 col1 = "#073B4C"
11 col2 = "#C7EDFA"
12 }
13 if (number == 2) {
14 col1 = "#118AB2"
15 col2 = "#B4E7F8"
16 }
17 if (number == 4) {
18 col1 = "#06DBA2"
19 col2 = "#AFFDE8"
20 }
21 if (number == 6) {
22 col1 = "#FFC233"
23 col2 = "#FFF3D6"
24 }
25 if (number == 8) {
26 col1 = "#EF436B"
27 col2 = "#FAC7D3"
28 }
29 if (number == 10) {
30 col1 = "#8377D1"
31 col2 = "#E2E0F5"
32 }
33
34 if (number == 0) {
35 plot(table$Energy, table$Impulses, type="l", col=col2, xlab="Energia (keV)", ylab="Comptes")
36 } else {
37 lines(table$Energy, table$Impulses, type="l", col=col2, xlab="Energia (keV)", ylab="Comptes")
38 }
39}
40
41plotfg <- function(table, number) {
42 col1 = ""
43 col2 = ""
44 if (number == 0) {
45 col1 = "#073B4C"
46 col2 = "#C7EDFA"
47 }
48 if (number == 2) {
49 col1 = "#118AB2"
50 col2 = "#B4E7F8"
51 }
52 if (number == 4) {
53 col1 = "#06DBA2"
54 col2 = "#AFFDE8"
55 }
56 if (number == 6) {
57 col1 = "#FFC233"
58 col2 = "#FFF3D6"
59 }
60 if (number == 8) {
61 col1 = "#EF436B"
62 col2 = "#FAC7D3"
63 }
64 if (number == 10) {
65 col1 = "#8377D1"
66 col2 = "#E2E0F5"
67 }
68
69 lines(table$Energy, table$ImpulsesSmooth, col=col1, type="l")
70}
71
72pdf(paste0('output/', nom, '.pdf'), width = 6, height = 5)
73numbers <- c(0:5)*2
74for (number in numbers) {
75 table <- read.table(paste0('dades/', nom, '_', number, '.txt'), sep="\t", dec='.', header=TRUE)
76 plotbg(table, number)
77}
78for (number in numbers) {
79 table <- read.table(paste0('dades/', nom, '_', number, '.txt'), sep="\t", dec='.', header=TRUE)
80 plotfg(table, number)
81}
82legendColors = c("#073B4C", "#118AB2", "#06DBA2", "#FFC233", "#EF436B", "#8377D1")
83legend("topright", inset = c(0.015, 0.03), col = legendColors, legend = c("Buit", "2 mangueres", "4 mangueres", "6 mangueres", "8 mangueres", "10 mangueres"), lty=c(1, 1, 1, 1, 1, 1))
84dev.off()
85
86tikz(paste0('output/', nom, '.tex'), width = 6, height = 5)
87numbers <- c(0:5)*2
88for (number in numbers) {
89 table <- read.table(paste0('dades/', nom, '_', number, '.txt'), sep="\t", dec='.', header=TRUE)
90 plotbg(table, number)
91}
92for (number in numbers) {
93 table <- read.table(paste0('dades/', nom, '_', number, '.txt'), sep="\t", dec='.', header=TRUE)
94 plotfg(table, number)
95}
96legendColors = c("#073B4C", "#118AB2", "#06DBA2", "#FFC233", "#EF436B", "#8377D1")
97legend("topright", inset = c(0.015, 0.03), col = legendColors, legend = c("Buit", "2 mangueres", "4 mangueres", "6 mangueres", "8 mangueres", "10 mangueres"), lty=c(1, 1, 1, 1, 1, 1))
98dev.off()