Skip to content

Commit

Permalink
Fix ggrepel version
Browse files Browse the repository at this point in the history
  • Loading branch information
camille-s committed Feb 7, 2024
1 parent 035e4b2 commit f83b2b3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Suggests:
knitr,
rmarkdown,
testthat (>= 3.0.0),
ggrepel,
ggrepel (== 0.9.4),
ragg,
withr
URL: https://github.com/CT-Data-Haven/stylehaven,
Expand Down
2 changes: 0 additions & 2 deletions man/add_logo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/endpoint_lbls.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions vignettes/dcws_example_plots.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -180,25 +180,27 @@ ggplot(cohesion, aes(x = question, y = value, color = group)) +
scale_color_manual(values = pal4,
guide = guide_legend(nrow = 2, byrow = TRUE, override.aes = list(size = 4))) +
theme(legend.position = "bottom",
panel.grid.major.y = element_line(size = 1, linetype = "11", color = "gray90")) +
panel.grid.major.y = element_line(linewidth = 1, linetype = "11", color = "gray90")) +
labs(x = NULL, y = NULL, color = NULL)
```

Fixing those overlapping points, plus adding a logo:

```{r dots2}
(to_dodge <- cohesion |>
dodge_lbls(x = question, value = value, group = group, thresh = 0.02))
```

```{r dots3, fig.width=plot_params$cohesion$w, fig.height=plot_params$cohesion$h, eval=require("ggrepel")}
plots[["cohesion"]] <- ggplot(cohesion, aes(x = question, y = value, color = group)) +
cohesion_dots <- ggplot(cohesion, aes(x = question, y = value, color = group)) +
geom_point(size = 9) +
geom_text(aes(label = percent100(value)),
geom_text(aes(label = percent100(value)),
data = ~anti_join(., to_dodge, by = c("question", "group")),
size = 3, color = "white") +
ggrepel::geom_text_repel(aes(label = percent100(value)),
data = ~semi_join(., to_dodge, by = c("question", "group")),
size = 3, fontface = "bold", family = "Barlow Semi Condensed",
direction = "x", nudge_x = 0.2, min.segment.length = 2, seed = 1,
direction = "x", nudge_x = 0.25, min.segment.length = 2, seed = 1,
segment.color = tf_pal[["TRUE"]], box.padding = 0.5, show.legend = FALSE) +
coord_flip() +
scale_x_discrete(labels = camiller::clean_titles) +
Expand All @@ -209,6 +211,7 @@ plots[["cohesion"]] <- ggplot(cohesion, aes(x = question, y = value, color = gro
panel.grid.major.y = element_line(size = 1, linetype = "11", color = "gray90")) +
labs(x = NULL, y = NULL, color = NULL)
plots[["cohesion"]] <- suppressWarnings(add_logo(cohesion_dots, place_inside = FALSE))
plots[["cohesion"]]
```

Expand Down

0 comments on commit f83b2b3

Please sign in to comment.