diff --git a/R/theme_ggswim.R b/R/theme_ggswim.R index c59d92c..38572a6 100644 --- a/R/theme_ggswim.R +++ b/R/theme_ggswim.R @@ -39,19 +39,19 @@ theme_ggswim <- function(base_size = 12, base_family = "") { theme_minimal(base_size = base_size, base_family = base_family) + theme( # Title and subtitle - plot.title = element_text(size = 18, face = "bold", hjust = 0, margin = margin(b = 10), colour = "#D67A00"), - plot.subtitle = element_text(size = 14, face = "bold", hjust = 0, margin = margin(b = 10), colour = "#FE9000"), + plot.title = element_text(size = 18, face = "bold", hjust = 0, margin = margin(b = 10), colour = "#000000"), + plot.subtitle = element_text(size = 14, face = "bold", hjust = 0, margin = margin(b = 10), colour = "#000000"), # Caption plot.caption = element_text(size = 10, hjust = 1), # Axis text - axis.text = element_text(size = 10, face = "bold", colour = "#0D2C54"), + axis.text = element_text(size = 10, face = "bold", colour = "#000000"), axis.text.x = element_text(margin = margin(t = 10)), axis.text.y = element_text(margin = margin(r = 10)), # Axis titles - axis.title = element_text(size = 12, face = "bold", colour = "#0D2C54"), + axis.title = element_text(size = 12, face = "bold", colour = "#000000"), axis.title.x = element_text(size = 14, face = "bold", margin = margin(t = 10)), axis.title.y = element_text(size = 14, face = "bold", margin = margin(r = 10)), @@ -60,17 +60,13 @@ theme_ggswim <- function(base_size = 12, base_family = "") { axis.ticks.length = unit(0.3, "cm"), # Legend - legend.text = element_text(size = 10, colour = "#0D2C54"), - legend.title = element_text(size = 12, face = "bold", colour = "#D67A00"), + legend.text = element_text(size = 10, colour = "#000000"), + legend.title = element_text(size = 12, face = "bold", colour = "#000000"), # Axis line axis.line = element_line( color = "steelblue", - linewidth = 1, - arrow = arrow( - type = "closed", - length = unit(0.1, "inches"), - ) + linewidth = 1 ), # Remove grid lines @@ -89,8 +85,8 @@ theme_ggswim_dark <- function(base_size = 12, base_family = "") { panel.background = element_rect(fill = "#232234", color = NA), # Title and subtitle - plot.title = element_text(size = 18, face = "bold", hjust = 0, margin = margin(b = 10), colour = "#FE9000"), - plot.subtitle = element_text(size = 14, face = "bold", hjust = 0, margin = margin(b = 10), colour = "#D67A00"), + plot.title = element_text(size = 18, face = "bold", hjust = 0, margin = margin(b = 10), colour = "#F0F0F0"), + plot.subtitle = element_text(size = 14, face = "bold", hjust = 0, margin = margin(b = 10), colour = "#F0F0F0"), # Caption plot.caption = element_text(size = 10, hjust = 1, colour = "#F0F0F0"), @@ -101,26 +97,22 @@ theme_ggswim_dark <- function(base_size = 12, base_family = "") { axis.text.y = element_text(margin = margin(r = 10), colour = "#F0F0F0"), # Axis titles - axis.title = element_text(size = 12, face = "bold", colour = "#FE9000"), - axis.title.x = element_text(size = 14, face = "bold", margin = margin(t = 10), colour = "#FE9000"), - axis.title.y = element_text(size = 14, face = "bold", margin = margin(r = 10), colour = "#FE9000"), + axis.title = element_text(size = 12, face = "bold", colour = "#F0F0F0"), + axis.title.x = element_text(size = 14, face = "bold", margin = margin(t = 10), colour = "#F0F0F0"), + axis.title.y = element_text(size = 14, face = "bold", margin = margin(r = 10), colour = "#F0F0F0"), # Axis tick marks - axis.ticks = element_line(linewidth = 0.75, colour = "#FE9000"), + axis.ticks = element_line(linewidth = 0.75, colour = "#F0F0F0"), axis.ticks.length = unit(0.3, "cm"), # Legend legend.text = element_text(size = 10, colour = "#F0F0F0"), - legend.title = element_text(size = 12, face = "bold", colour = "#FE9000"), + legend.title = element_text(size = 12, face = "bold", colour = "#F0F0F0"), # Axis line axis.line = element_line( - color = "#FE9000", # Orange axis line - linewidth = 1, - arrow = arrow( - type = "closed", - length = unit(0.1, "inches") - ) + color = "#F0F0F0", # Orange axis line + linewidth = 1 ), # Remove grid lines diff --git a/README.Rmd b/README.Rmd index 8c68f13..fcc8156 100644 --- a/README.Rmd +++ b/README.Rmd @@ -117,7 +117,7 @@ Using the custom `marker` `aes()` in `geom_swim_marker()` in combination with sp p + scale_colour_brewer(name = "Lanes", palette = "Set1") + labs(title = "My Swimmer Plot") + - xlab("Time Since Infusion (Months)") + ylab("Patient ID") + + xlab("Time Since Initial Infusion (Months)") + ylab("Patient ID") + theme_ggswim() ``` diff --git a/README.md b/README.md index cd47af4..6a3546f 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ ggplot2 techniques and a last finishing touch with `theme_ggswim()`: p + scale_colour_brewer(name = "Lanes", palette = "Set1") + labs(title = "My Swimmer Plot") + - xlab("Time Since Infusion (Months)") + ylab("Patient ID") + + xlab("Time Since Initial Infusion (Months)") + ylab("Patient ID") + theme_ggswim() ``` diff --git a/data/infusion_events.rda b/data/infusion_events.rda index 00fc49c..b447fb4 100644 Binary files a/data/infusion_events.rda and b/data/infusion_events.rda differ diff --git a/man/figures/README-unnamed-chunk-3-1.png b/man/figures/README-unnamed-chunk-3-1.png index 8f44d37..1f0a86a 100644 Binary files a/man/figures/README-unnamed-chunk-3-1.png and b/man/figures/README-unnamed-chunk-3-1.png differ diff --git a/man/figures/README-unnamed-chunk-4-1.png b/man/figures/README-unnamed-chunk-4-1.png index 98023b7..f3364cc 100644 Binary files a/man/figures/README-unnamed-chunk-4-1.png and b/man/figures/README-unnamed-chunk-4-1.png differ diff --git a/man/figures/README-unnamed-chunk-5-1.png b/man/figures/README-unnamed-chunk-5-1.png index 5fdeebc..3e334c5 100644 Binary files a/man/figures/README-unnamed-chunk-5-1.png and b/man/figures/README-unnamed-chunk-5-1.png differ diff --git a/tests/testthat/_snaps/geom_swim_arrow/arrows-work-with-simple-plot.svg b/tests/testthat/_snaps/geom_swim_arrow/arrows-work-with-simple-plot.svg index a0e393f..9f88818 100644 --- a/tests/testthat/_snaps/geom_swim_arrow/arrows-work-with-simple-plot.svg +++ b/tests/testthat/_snaps/geom_swim_arrow/arrows-work-with-simple-plot.svg @@ -100,24 +100,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + ⚠️ @@ -142,22 +142,21 @@ - -01 -02 -03 -04 -05 -06 -08 -09 -12 -13 -14 -15 -17 -18 -19 +01 +02 +03 +04 +05 +06 +08 +09 +12 +13 +14 +15 +17 +18 +19 @@ -174,41 +173,40 @@ - --5 -0 -5 -10 -15 -start_time -pt_id -Lanes +-5 +0 +5 +10 +15 +start_time +pt_id +Lanes -CR -CR/CRi + B Cell Aplasia -CR/CRi + B Cell Recovery -CRi -RD -Marker - - +CR +CR/CRi + B Cell Aplasia +CR/CRi + B Cell Recovery +CRi +RD +Marker + + ⚠️ -Initial Infusion -Reinfusion -Other End Study Reason -Deceased -Completed Study Follow-Up -Arrows work with simple plot +First Reinfusion +Second Reinfusion +Other End Study Reason +Deceased +Completed Study Follow-Up +Arrows work with simple plot diff --git a/tests/testthat/_snaps/geom_swim_marker/geom-swim-marker-works-with-inherited-data-and-params.svg b/tests/testthat/_snaps/geom_swim_marker/geom-swim-marker-works-with-inherited-data-and-params.svg index 9476f7e..afcdb37 100644 --- a/tests/testthat/_snaps/geom_swim_marker/geom-swim-marker-works-with-inherited-data-and-params.svg +++ b/tests/testthat/_snaps/geom_swim_marker/geom-swim-marker-works-with-inherited-data-and-params.svg @@ -21,31 +21,31 @@ - - + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + 01 @@ -78,26 +78,24 @@ - - - - - -0 -1 -2 -3 -4 -time_from_initial_infusion + + + + +0 +2 +4 +6 +time_from_initial_infusion pt_id - -label - - - - -Initial Infusion -Reinfusion + +label + + + + +First Reinfusion +Second Reinfusion geom_swim_marker works with inherited data and params diff --git a/vignettes/articles/gallery.Rmd b/vignettes/articles/gallery.Rmd index 50ae3e5..7d20aad 100644 --- a/vignettes/articles/gallery.Rmd +++ b/vignettes/articles/gallery.Rmd @@ -24,21 +24,21 @@ library(dplyr) In this example, we'll set up a random dataset for reproducibility by separately defining a dataframe for our lanes and our markers. ```{r} -set.seed(123) +set.seed(123) lane_data <- tibble( x = 0, xend = sample(5:20, 30, replace = TRUE), y = factor(rep(1:15, each = 2)), - colour = sample(c('red', 'blue', 'green', 'yellow', 'purple'), 30, replace = TRUE) + colour = sample(c("red", "blue", "green", "yellow", "purple"), 30, replace = TRUE) ) -set.seed(123) +set.seed(123) marker_data <- tibble( x = sample(5:20, 30, replace = TRUE), y = factor(rep(1:15, each = 2)), label = sample(c("A", "B", "C", "D", "E"), 30, replace = TRUE), glyph = sample(c("😊", "🎉", "✅", "💥", "✨"), 30, replace = TRUE) -) |> +) |> mutate( glyph = dplyr::case_when( label == "A" ~ "😊", @@ -50,9 +50,9 @@ marker_data <- tibble( ) ) -lane_data |> +lane_data |> rmarkdown::paged_table() -marker_data |> +marker_data |> rmarkdown::paged_table() ```