pY <- ggplot(sim_df, aes(x = Y)) +
geom_histogram(aes(y = after_stat(density)),
fill = 'goldenrod', color = 'black',
binwidth = 0.02, center = 0.01) +
geom_line(aes(y = fY), color = "red", linewidth = 1) +
xlim(0, 1) + ylim(0, 2.5) +
labs(x = 'Y', y = expression(f[Y](y))) +
theme_classic(base_size = 14)
pU <- ggplot(sim_df, aes(x = U)) +
geom_histogram(aes(y = after_stat(density)),
fill = 'cornflowerblue', color = 'black',
binwidth = 0.02, center = -0.99) +
geom_line(aes(y = (1-U)/2), color = "red", linewidth = 1) +
scale_x_reverse() +
ylim(0, 1.5) +
labs(x = 'U', y = expression(f[U](u))) +
theme_classic(base_size = 14)
pV <- ggplot(sim_df, aes(x = V)) +
geom_histogram(aes(y = after_stat(density)),
fill = 'red', color = 'black',
binwidth = 0.05, center = 1.01) +
geom_line(aes(y = fV), color = "red", linewidth = 1) +
xlim(1, 10) +
labs(x = 'V', y = expression(f[V](v))) +
theme_classic(base_size = 14)
pW <- ggplot(sim_df, aes(x = W)) +
geom_histogram(aes(y = after_stat(density)),
fill = 'lightgreen', color = 'black',
binwidth = 0.02, center = 0.01) +
geom_line(aes(y = fW), color = "red", linewidth = 1) +
xlim(0, 1) + ylim(0, 1.5) +
labs(x = 'W', y = expression(f[W](w))) +
theme_classic(base_size = 14)
combined_plot <- (pY | pU) / (pV | pW)
combined_plot