library(OpenLand)
library(ggplot2)
# Load and prepare data
data(SL_2002_2014)
testSL <- intensityAnalysis(
dataset = SL_2002_2014,
category_n = "Ap",
category_m = "SG"
)
# Create output directory
dir.create("publication_figures", showWarnings = FALSE)
# Define publication theme
pub_theme <- theme_bw() +
theme(
axis.text = element_text(size = 11, color = "black"),
axis.title = element_text(size = 12, face = "bold"),
legend.text = element_text(size = 10),
legend.title = element_text(size = 11, face = "bold"),
legend.position = "right",
panel.grid.minor = element_blank(),
strip.background = element_rect(fill = "white", color = "black"),
strip.text = element_text(size = 11, face = "bold")
)
# Export all figures as TIFF (300 DPI)
figures <- list(
list(name = "Fig1_interval", obj = testSL$interval_lvl,
labels = c(leftlabel = "Interval Change Area (%)",
rightlabel = "Annual Change Area (%)")),
list(name = "Fig2_category_gain", obj = testSL$category_lvlGain,
labels = c(leftlabel = bquote("Gain Area (" ~ km^2 ~ ")"),
rightlabel = "Intensity Gain (%)")),
list(name = "Fig3_category_loss", obj = testSL$category_lvlLoss,
labels = c(leftlabel = bquote("Loss Area (" ~ km^2 ~ ")"),
rightlabel = "Loss Intensity (%)")),
list(name = "Fig4_transition_gain", obj = testSL$transition_lvlGain_n,
labels = c(leftlabel = bquote("Gain of Ap (" ~ km^2 ~ ")"),
rightlabel = "Intensity Gain of Ap (%)")),
list(name = "Fig5_transition_loss", obj = testSL$transition_lvlLoss_m,
labels = c(leftlabel = bquote("Loss of SG (" ~ km^2 ~ ")"),
rightlabel = "Intensity Loss of SG (%)"))
)
for (fig in figures) {
tiff(
filename = paste0("publication_figures/", fig$name, ".tiff"),
width = 3000,
height = 2000,
res = 300,
compression = "lzw"
)
plot(
fig$obj,
labels = fig$labels,
marginplot = c(.3, .3),
leg_curv = c(x = 0.5, y = 0.5),
fontsize_ui = 10,
pub_theme
)
dev.off()
}
print("All publication figures saved!")