Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support autoformatting of ggrepel functions #43

Open
py9mrg opened this issue Oct 29, 2020 · 1 comment
Open

Support autoformatting of ggrepel functions #43

py9mrg opened this issue Oct 29, 2020 · 1 comment
Assignees
Labels
priority: medium Medium priority status: planned Planning to implement

Comments

@py9mrg
Copy link

py9mrg commented Oct 29, 2020

Hello,

I was wondering how much hassle it would be to include support for the ggrepel functions? Obviously we can manually do this with something like:

  update_geom_defaults("text_repel",
                       list(family = "desired font", color = "desired color"))

and similar for label_repel. But if theme_xaringan() could do it for us that would be nice. I guess it shouldn't be too tricky to add a ggrepel = TRUE argument into theme_xaringan(), and whack in an if statement - but if it could automatically pick up any geoms that are text or label and then set those accordingly, that might be quite a convenient solution (for the user). Assuming there's no extension packages around that have those in their geom names - which could make this more hassle than it's worth! Here's an MWE of what I mean:

---
title: "Example"
output: html_document
---
knitr::opts_chunk$set(echo = TRUE)
library(ggplot2)
library(tidyverse)
library(xaringanthemer)
style_mono_accent(
  base_color = "#DC322F",               # bright red
  inverse_background_color = "#002B36", # dark dark blue
  inverse_header_color = "#31b09e",     # light aqua green
  inverse_text_color = "#FFFFFF",       # white
  title_slide_background_color = "var(--base)",
  text_font_google = google_font("Kelly Slab"),
  header_font_google = google_font("Oleo Script")
)
data <- tibble( 
  label = LETTERS[1:5],
  x = 1:5,
  y = (1:5)^2
)

p_text <- data %>%
  ggplot(aes(x = x, y = y, label = label)) +
  geom_text() +
  theme_xaringan()
p_text

image

library(ggrepel)

p_repel <- data %>%
  ggplot(aes(x = x, y = y, label = label)) +
  geom_text_repel() +
  theme_xaringan()
p_repel

image

@gadenbuie gadenbuie self-assigned this Oct 29, 2020
@gadenbuie gadenbuie added priority: medium Medium priority status: planned Planning to implement labels Oct 29, 2020
@gadenbuie
Copy link
Owner

This seems reasonable. I think we could condition on testing if ggrepel is installed before setting the defaults. Thanks for the reprex!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: medium Medium priority status: planned Planning to implement
Projects
None yet
Development

No branches or pull requests

2 participants