blob: 912b96aee38b2bd59e1df5f3405971ff860da417 [file] [log] [blame]
Adrià Vilanova Martínez6785f9f2023-04-20 02:13:51 +02001library(svglite)
2library(tikzDevice)
3
4filename = '0.02_lif'
5scale <- 200
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, 9000))
15
16 # Add arrows and text labels to the peaks
17 i <- 154
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), '$\\mathbf{K}_{\\beta}$', col = "#F03A47", cex = 0.75)
20
21 i <- 177
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), '$\\mathbf{K}_{\\alpha 2}$', col = "#F03A47", cex = 0.75)
24
25 i <- 390
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), '$\\mathbf{K}_{\\beta}$', col = "#F03A47", cex = 0.75)
28
29 i <- 452
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), '$\\mathbf{K}_{\\alpha 1}$', 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}