Skip to content

Commit

Permalink
increased variance of a group for t2 and other minor plot changes
Browse files Browse the repository at this point in the history
  • Loading branch information
njudd committed Dec 4, 2024
1 parent b229924 commit 6948f93
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions inst/fig2.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

## figure creation for 'ggrain' manuscript to Journal of Open Source Software

## Use and pre-load to setwd() all documents in : "Workshop8 - Brain development day"
## Use and pre-load to setwd() all documents in : "Workshop8 - Brain development day"

if (!require(pacman)) {install.packages("pacman")}
pacman::p_load(patchwork, tidyverse, ggrain)
pacman::p_load(patchwork, tidyverse, ggrain)

#################################################
# first we will start by simulating some data! :)
Expand All @@ -24,34 +24,43 @@ df <- data.frame(score = c(groupa, groupb), group = c(rep("A", length(groupa)),

## simple figure

p_simple <- ggplot(simdat, aes(x=group,y=score, fill = group, colour = group)) +
p_simple <- ggplot(df, aes(x=group,y=score, fill = group)) +
geom_rain(rain.side = "r",
boxplot.args = list(color = "black", outlier.color = NA)) +
point.args = list(alpha = .8),
boxplot.args = list(color = "black", outlier.color = NA)) +
scale_color_brewer(palette = "Dark2") + scale_fill_brewer(palette = "Dark2") +
theme_minimal(base_size = 26)
labs(x = "") +
theme_minimal(base_size = 30)

# making long data
g_A1 <- rnorm(15, 6.5, 2)
set.seed(22)
g_A2 <- rnorm(15, 6.5, 2) + rnorm(15) + 1
g_A2 <- rnorm(15, 6.5, 2) + rnorm(15, 1, 1) + 3

g_A1 <- abs(g_A1) # zero cesoring

g_B1 <- c(rnorm(14, 2, .8), 8.5)
g_B1 <- abs(g_B1) # zero cesoring

g_B1 <- c(rnorm(14, 2, 1), 8.1)
set.seed(24)
g_B2 <- c(rnorm(14, 2, 1), 8.9) + rnorm(15) + 1
g_B2 <- c(rnorm(14, 2, 2), 8.9) + rnorm(15,1,1) + 3

df2 <- data.frame(score = c(g_A1, g_A2, g_B1, g_B2),
df2 <- data.frame(score = c(g_A1, g_A2, g_B1, g_B2),
id = as.character(c(rep(1:15), rep(1:15), rep(16:30), rep(16:30))),
time = c(rep("1", 15), rep("2", 15), rep("1", 15), rep("2", 15)),
time = c(rep("pre", 15), rep("post", 15), rep("pre", 15), rep("post", 15)),
group = c(rep("A", 30), rep("B", 30)))
df2$time <- factor(df2$time, levels = c("pre", "post"))

# making a more complex long data fig

p_complex <- ggplot(df2, aes(x = time, y = score, fill = group, color = group)) +
geom_rain(id.long.var = "id", rain.side = "f2x2",
boxplot.args = list(color = "black", outlier.color = NA),
violin.args = list(adjust = 1.5, trim = FALSE)) +
violin.args = list(adjust = 1.5, trim = FALSE, alpha = .5)) +
scale_color_brewer(palette = "Dark2") + scale_fill_brewer(palette = "Dark2") +
theme_minimal(base_size = 26)
labs(x = "") +
theme_minimal(base_size = 30)


p_all <- p_simple / p_complex + plot_annotation(tag_levels = "a")

Expand Down

0 comments on commit 6948f93

Please sign in to comment.