Skip to content

Commit 0c0df14

Browse files
committed
Added labels, axes, margin, and legend
1 parent 17c3023 commit 0c0df14

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

analyses/plotResults.R

+22-6
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,35 @@ nbCohorts = dim(dyn)[1]/nbTimeSteps - ifelse(end[.N, density] == 0, 1, 0)
3535

3636
#### Tikz plots
3737
tikz("./noDisp.tex", width = 3.1, height = 3.1) #, standAlone = TRUE)
38-
op <- par(mar = c(2.5, 2.5, 0.8, 0.8), mgp = c(1.5, 0.3, 0), tck = -0.015)
38+
op <- par(mar = c(2.5, 2.5, 2.5, 0.8), mgp = c(1.5, 0.3, 0), tck = -0.015)
39+
xmax = max(end[, dbh])
40+
ymax = max(end[, density])
41+
plot(x = NULL, y = NULL, xlim = c(0, xmax + 0.1),
42+
ylim = c(0, ymax + 0.1), axes = FALSE, xlab = "Size",
43+
ylab = "Density")
3944
for (i in 1:nbCohorts)
4045
{
4146
# Initial state
42-
tikzCoord(init[i, dbh], 0, paste0("init_start_", i), units = "device")
43-
tikzCoord(init[i, dbh], init[i, density], paste0("init_end_", i), units = "device")
47+
tikzCoord(init[i, dbh], 0, paste0("init_start_", i))
48+
tikzCoord(init[i, dbh], init[i, density], paste0("init_end_", i))
4449
tikzAnnotate(paste0("\\draw (init_start_", i, ") -- (init_end_", i, ");"))
4550

4651
# End state
47-
tikzCoord(end[i, dbh], 0, paste0("end_start_", i), units = "device")
48-
tikzCoord(end[i, dbh], end[i, density], paste0("end_end_", i), units = "device")
49-
tikzAnnotate(paste0("\\draw[dashed] (end_start_", i, ") -- (end_end_", i, ");"))
52+
tikzCoord(end[i, dbh], 0, paste0("end_start_", i))
53+
tikzCoord(end[i, dbh], end[i, density], paste0("end_end_", i))
54+
tikzAnnotate(paste0("\\draw[dashed] (end_end_", i, ") -- (end_start_", i, ");"))
55+
56+
# Arrow movement
57+
tikzAnnotate(paste0("\\draw[arrow, draw = orange] (init_end_", i, ") -- (end_end_", i, ");"))
5058
}
59+
# Axes
60+
axis(side = 1, at = 0:xmax, labels = 0:xmax)
61+
axis(side = 2, at = 0:ymax, labels = 0:ymax)
62+
63+
# Legend
64+
legend(x = "topleft", legend = c("t = 0", "t = 3"), xpd = TRUE,
65+
lty = c("solid", "dashed"), lwd = 2, bty = "n", inset = c(0, -0.15))
66+
5167
dev.off()
5268

5369
######## Part II: Population dynamics

0 commit comments

Comments
 (0)