blob: 47cc204a22c4340da4484403497d9cd979f78f4e [file] [log] [blame]
library(tikzDevice)
table <- read.table('../dades/dades.txt', sep="\t", header=TRUE)
table$logI <- log(table$impulsosPerSegon)
fit_lineal <- lm(logI~gruixMassic, data = table)
summary(fit_lineal)
fit_coef <- coef(fit_lineal)
fit_coef
plotall <- function() {
plot(table$gruixMassic, table$logI, pch = 4, xlab = "$t$ (g cm\\textsuperscript{-2})", ylab = "$\\log(I)$")
abline(fit_lineal, col = "mediumorchid2")
legend("topright", inset = c(0.015, 0.03),col = c("black", "mediumorchid2"), legend = c("Mesures", "Ajust"), pch=c(4, NA), lty=c(NA, 1))
}
plotallnormal <- function() {
plot(table$gruixMassic, table$impulsosPerSegon, pch = 4, xlab = "$t$ (g cm\\textsuperscript{-2})", ylab = "$I$ (\\#s \\textsuperscript{-1})")
curve(exp(fit_coef[1] + x*fit_coef[2]), col = "mediumorchid2", add = TRUE)
legend("topright", inset = c(0.015, 0.03),col = c("black", "mediumorchid2"), legend = c("Mesures", "Ajust"), pch=c(4, NA), lty=c(NA, 1))
}
pdf('grafica.pdf', width = 6, height = 5)
plotall()
dev.off()
tikz("grafica.tex", width = 5.5, height = 4.5)
plotall()
dev.off()
pdf('graficanormal.pdf', width = 6, height = 5)
plotallnormal()
dev.off()
tikz("graficanormal.tex", width = 5.5, height = 4.5)
plotallnormal()
dev.off()