blob: 3c8f06e898ca76656f1ef11edfa9689b311e6f6e [file] [log] [blame]
library(svglite)
library(tikzDevice)
filename = 'ni0.01_kbr'
scale <- 75
args = commandArgs(trailingOnly=TRUE)
table <- read.table(paste0('dades/', filename, '.txt'), sep="\t", dec=',', header=FALSE, col.names=c('Theta', 'I'))
# Plot the data
plotall <- function() {
par(mar=c(4,4,0.5,0.5))
plot(table$Theta, table$I, type="l", xlab="$\\theta$ (ยบ)", ylab="$I$ (\\#/s)", ylim=c(0, 3500))
# Add arrows and text labels to the peaks
i <- 87
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")
text(table$Theta[i], table$I[i] + scale*(5.2 + 2), '$n = 1$', col = "#F03A47", cex = 0.75)
i <- 231
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")
text(table$Theta[i], table$I[i] + scale*(5.2 + 2), '$n = 2$', col = "#F03A47", cex = 0.75)
i <- 396
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")
text(table$Theta[i], table$I[i] + scale*(5.2 + 2), '$n = 3$', col = "#F03A47", cex = 0.75)
i <- 639
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")
text(table$Theta[i], table$I[i] + scale*(5.2 + 2), '$n = 4$', col = "#F03A47", cex = 0.75)
}
svg(paste0('output/', filename, '.svg'), width = 4*0.82, height = 3*0.82)
plotall()
dev.off()
if (length(args) < 1 || args[1] != "preview") {
tikz(paste0('output/', filename, '.tex'), width = 4*0.82, height = 3*0.82)
plotall()
dev.off()
}