blob: d0db5dda788cd57e6bfa7c297f2cc260349296f8 [file] [log] [blame]
library(svglite)
library(tikzDevice)
filename = 'regressio'
args = commandArgs(trailingOnly=TRUE)
table <- read.table(paste0('dades/', filename, '.txt'), sep=" ", dec='.', header=TRUE)
fit <- lm(X ~ Y, data = table)
summary(fit)
# Plot the data
plotall <- function() {
par(mar=c(4,4,0.5,0.5))
plot(table$Y, table$X, pch = 4, xlab = "$\\sin(\\theta)$", ylab = "$\\frac{n \\lambda}{2}$ (pm)")
abline(fit, col = "#799B6F")
}
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()
}