blob: 3c8f06e898ca76656f1ef11edfa9689b311e6f6e [file] [log] [blame]
Adrià Vilanova Martínez6785f9f2023-04-20 02:13:51 +02001library(svglite)
2library(tikzDevice)
3
4filename = 'ni0.01_kbr'
5scale <- 75
6
7args = commandArgs(trailingOnly=TRUE)
8
9table <- read.table(paste0('dades/', filename, '.txt'), sep="\t", dec=',', header=FALSE, col.names=c('Theta', 'I'))
10
11# Plot the data
12plotall <- function() {
13 par(mar=c(4,4,0.5,0.5))
14 plot(table$Theta, table$I, type="l", xlab="$\\theta$ (º)", ylab="$I$ (\\#/s)", ylim=c(0, 3500))
15
16 # Add arrows and text labels to the peaks
17 i <- 87
18 arrows(table$Theta[i], table$I[i] + scale*(3 + 2), table$Theta[i], table$I[i] + scale*0.2, length = 0.05, code = 1, col = "#F03A47")
19 text(table$Theta[i], table$I[i] + scale*(5.2 + 2), '$n = 1$', col = "#F03A47", cex = 0.75)
20
21 i <- 231
22 arrows(table$Theta[i], table$I[i] + scale*(3 + 2), table$Theta[i], table$I[i] + scale*0.2, length = 0.05, code = 1, col = "#F03A47")
23 text(table$Theta[i], table$I[i] + scale*(5.2 + 2), '$n = 2$', col = "#F03A47", cex = 0.75)
24
25 i <- 396
26 arrows(table$Theta[i], table$I[i] + scale*(3 + 2), table$Theta[i], table$I[i] + scale*0.2, length = 0.05, code = 1, col = "#F03A47")
27 text(table$Theta[i], table$I[i] + scale*(5.2 + 2), '$n = 3$', col = "#F03A47", cex = 0.75)
28
29 i <- 639
30 arrows(table$Theta[i], table$I[i] + scale*(3 + 2), table$Theta[i], table$I[i] + scale*0.2, length = 0.05, code = 1, col = "#F03A47")
31 text(table$Theta[i], table$I[i] + scale*(5.2 + 2), '$n = 4$', col = "#F03A47", cex = 0.75)
32}
33
34svg(paste0('output/', filename, '.svg'), width = 4*0.82, height = 3*0.82)
35plotall()
36dev.off()
37
38if (length(args) < 1 || args[1] != "preview") {
39 tikz(paste0('output/', filename, '.tex'), width = 4*0.82, height = 3*0.82)
40 plotall()
41 dev.off()
42}