Adrià Vilanova Martínez | 6785f9f | 2023-04-20 02:13:51 +0200 | [diff] [blame] | 1 | library(svglite) |
| 2 | library(tikzDevice) |
| 3 | |
| 4 | filename = '0.02_lif' |
| 5 | scale <- 200 |
| 6 | |
| 7 | args = commandArgs(trailingOnly=TRUE) |
| 8 | |
| 9 | table <- read.table(paste0('dades/', filename, '.txt'), sep="\t", dec=',', header=FALSE, col.names=c('Theta', 'I')) |
| 10 | |
| 11 | # Plot the data |
| 12 | plotall <- 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 | |
| 34 | svg(paste0('output/', filename, '.svg'), width = 4*0.82, height = 3*0.82) |
| 35 | plotall() |
| 36 | dev.off() |
| 37 | |
| 38 | if (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 | } |