blob: d0db5dda788cd57e6bfa7c297f2cc260349296f8 [file] [log] [blame]
Adrià Vilanova Martínez6785f9f2023-04-20 02:13:51 +02001library(svglite)
2library(tikzDevice)
3
4filename = 'regressio'
5
6args = commandArgs(trailingOnly=TRUE)
7
8table <- read.table(paste0('dades/', filename, '.txt'), sep=" ", dec='.', header=TRUE)
9
10fit <- lm(X ~ Y, data = table)
11summary(fit)
12
13# Plot the data
14plotall <- function() {
15 par(mar=c(4,4,0.5,0.5))
16 plot(table$Y, table$X, pch = 4, xlab = "$\\sin(\\theta)$", ylab = "$\\frac{n \\lambda}{2}$ (pm)")
17 abline(fit, col = "#799B6F")
18}
19
20svg(paste0('output/', filename, '.svg'), width = 4*0.82, height = 3*0.82)
21plotall()
22dev.off()
23
24if (length(args) < 1 || args[1] != "preview") {
25 tikz(paste0('output/', filename, '.tex'), width = 4*0.82, height = 3*0.82)
26 plotall()
27 dev.off()
28}