Final Draft (Hopefully)
This commit is contained in:
58
plot1/plot.R
58
plot1/plot.R
@@ -14,6 +14,9 @@ data_t1 <- read_csv(
|
||||
0.080,0.095,0.780"
|
||||
)
|
||||
|
||||
data_t1$cat <- rep("Theoretical", 8)
|
||||
colnames(data_t1) <- c("m1", "m2", "a_measured", "Theoretical")
|
||||
|
||||
a_theoretical <- function(m) {
|
||||
9.81 * m
|
||||
}
|
||||
@@ -40,6 +43,14 @@ lm_eqn <- function(df) {
|
||||
as.character(as.expression(eq))
|
||||
}
|
||||
|
||||
th_eqn <- function() {
|
||||
eq <- substitute(
|
||||
italic(y) == b %.% italic(x),
|
||||
list(b = format(unname(9.81), digits = 3))
|
||||
)
|
||||
as.character(as.expression(eq))
|
||||
}
|
||||
|
||||
data_t1["M"] <- m_from_masses(data_t1["m1"], data_t1["m2"])
|
||||
|
||||
data_t1["a"] <- data_t1$M * 9.8
|
||||
@@ -49,18 +60,31 @@ plt <- ggplot(
|
||||
mapping = aes(x = M, y = a_measured)
|
||||
) +
|
||||
geom_point(
|
||||
col = "#D55E00",
|
||||
size = 2,
|
||||
aes(color = "D55E00"),
|
||||
size = 8,
|
||||
) +
|
||||
geom_smooth(
|
||||
se = FALSE,
|
||||
method = "lm",
|
||||
linewidth = 0.8,
|
||||
linewidth = 2.6,
|
||||
col = "#D55E00",
|
||||
) +
|
||||
geom_segment(aes(x = min(data_t1$M),
|
||||
y = a_theoretical(min(data_t1$M)),
|
||||
xend = max(data_t1$M),
|
||||
yend = a_theoretical(max(data_t1$M)),
|
||||
linetype = "Theoretical"),
|
||||
size = 2.2,
|
||||
color = "#0072B2"
|
||||
) +
|
||||
theme(
|
||||
axis.text = element_text(size = 14),
|
||||
axis.title = element_text(size = 20),
|
||||
axis.text = element_text(size = 32),
|
||||
axis.title = element_text(size = 50),
|
||||
panel.grid.minor = element_line(size = 1.5),
|
||||
panel.grid.major = element_line(size = 2),
|
||||
legend.title = element_blank(),
|
||||
legend.text = element_text(size = 36),
|
||||
legend.key.size = unit(8, "line")
|
||||
) +
|
||||
labs(
|
||||
x = x_lab(),
|
||||
@@ -70,29 +94,25 @@ plt <- ggplot(
|
||||
label = lm_eqn(data_t1[, c("a_measured", "M")]),
|
||||
x = 0.076,
|
||||
y = 0.58,
|
||||
size = 5,
|
||||
size = 18,
|
||||
col = "#D55E00",
|
||||
parse = TRUE,
|
||||
) +
|
||||
annotate("segment",
|
||||
x = min(data_t1$M),
|
||||
y = a_theoretical(min(data_t1$M)),
|
||||
xend = max(data_t1$M),
|
||||
yend = a_theoretical(max(data_t1$M)),
|
||||
linewidth = 0.8,
|
||||
col = "#0072B2",
|
||||
) +
|
||||
annotate("text",
|
||||
label = "Theoretical",
|
||||
label = th_eqn(),
|
||||
x = 0.068,
|
||||
y = 0.74,
|
||||
col = "#0072B2",
|
||||
size = 5,
|
||||
)
|
||||
size = 18,
|
||||
parse = TRUE,
|
||||
) +
|
||||
scale_color_manual(name = "", values = c("#D55E00"), labels = "Measured") +
|
||||
scale_linewidth_manual("Theoretical", values = c("Theoretical" = 2))
|
||||
|
||||
plt
|
||||
|
||||
ggsave("plot.pdf",
|
||||
ggsave("plot.svg",
|
||||
plot = plt,
|
||||
device = cairo_pdf,
|
||||
width = 30,
|
||||
height = 25,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user