# PlotX synthetic examples. Invented data, not research findings. # Requires ggplot2 and ragg, plus DejaVu Sans for the original typography. # Run in an output folder with: Rscript synthetic-figures.R # Package and font versions may change precise rendering. stopifnot(requireNamespace("ggplot2", quietly = TRUE), requireNamespace("ragg", quietly = TRUE)) library(ggplot2) set.seed(27) observations <- data.frame(nitrogen = seq(10, 90, length.out = 24)) observations$yield <- 1.5 + observations$nitrogen * 0.055 + rnorm(24, sd = 0.65) scatter <- ggplot(observations, aes(nitrogen, yield)) + geom_smooth(method = "lm", formula = y ~ x, color = "#3b72f6", fill = "#dce8ff", linewidth = 0.65) + geom_point(color = "#3262ed", size = 2) + labs(x = "Nitrogen", y = "Yield") + theme_classic(base_family = "DejaVu Sans", base_size = 9) + theme(axis.line = element_line(color = "#9ba3b2", linewidth = 0.3), axis.ticks = element_line(color = "#9ba3b2", linewidth = 0.3), plot.margin = margin(16, 16, 12, 12)) groups <- data.frame(treatment = rep(c("T1", "T2", "T3"), each = 18), value = c(rnorm(18, 4, 0.7), rnorm(18, 5, 0.9), rnorm(18, 6, 0.8))) box <- ggplot(groups, aes(treatment, value, fill = treatment)) + geom_boxplot(width = 0.55, linewidth = 0.4) + scale_fill_manual(values = c("#aa86ff", "#66a9ff", "#6bc5ac")) + labs(x = "Treatment", y = "Response") + theme_classic(base_family = "DejaVu Sans", base_size = 9) + theme(legend.position = "none", axis.line = element_line(color = "#9ba3b2", linewidth = 0.3), plot.margin = margin(16, 16, 12, 12)) ggsave("plotx-synthetic-scatter.png", scatter, device = ragg::agg_png, width = 3.5, height = 3.2, dpi = 200, bg = "white") ggsave("plotx-synthetic-boxplot.png", box, device = ragg::agg_png, width = 3.5, height = 3.2, dpi = 200, bg = "white") write.csv(observations, "plotx-synthetic-relationship.csv", row.names = FALSE) write.csv(groups, "plotx-synthetic-groups.csv", row.names = FALSE)