Adrià Vilanova MartÃnez | 42b8a89 | 2023-03-21 00:18:28 +0100 | [diff] [blame] | 1 | library(tikzDevice) |
| 2 | |
| 3 | nom <- 'Pic_Am' |
| 4 | scale <- 4 |
| 5 | |
| 6 | plotbg <- 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 | |
| 41 | plotfg <- 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 | |
| 72 | pdf(paste0('output/', nom, '.pdf'), width = 6, height = 5) |
| 73 | numbers <- c(0:5)*2 |
| 74 | for (number in numbers) { |
| 75 | table <- read.table(paste0('dades/', nom, '_', number, '.txt'), sep="\t", dec='.', header=TRUE) |
| 76 | plotbg(table, number) |
| 77 | } |
| 78 | for (number in numbers) { |
| 79 | table <- read.table(paste0('dades/', nom, '_', number, '.txt'), sep="\t", dec='.', header=TRUE) |
| 80 | plotfg(table, number) |
| 81 | } |
| 82 | legendColors = c("#073B4C", "#118AB2", "#06DBA2", "#FFC233", "#EF436B", "#8377D1") |
| 83 | legend("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)) |
| 84 | dev.off() |
| 85 | |
| 86 | tikz(paste0('output/', nom, '.tex'), width = 6, height = 5) |
| 87 | numbers <- c(0:5)*2 |
| 88 | for (number in numbers) { |
| 89 | table <- read.table(paste0('dades/', nom, '_', number, '.txt'), sep="\t", dec='.', header=TRUE) |
| 90 | plotbg(table, number) |
| 91 | } |
| 92 | for (number in numbers) { |
| 93 | table <- read.table(paste0('dades/', nom, '_', number, '.txt'), sep="\t", dec='.', header=TRUE) |
| 94 | plotfg(table, number) |
| 95 | } |
| 96 | legendColors = c("#073B4C", "#118AB2", "#06DBA2", "#FFC233", "#EF436B", "#8377D1") |
| 97 | legend("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)) |
| 98 | dev.off() |