Adrià Vilanova Martínez | 6785f9f | 2023-04-20 02:13:51 +0200 | [diff] [blame] | 1 | library(svglite) |
| 2 | library(tikzDevice) |
| 3 | |
| 4 | filename = 'ni0.01_kbr' |
| 5 | scale <- 75 |
| 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, 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 | |
| 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 | } |