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

themes_*() scale relevant elements with argument base_size. #382

Merged
merged 12 commits into from
Jan 31, 2025

Conversation

strengejacke
Copy link
Member

This allows us to scale a plot and ensure that proportions of all relevant plot-elements (mostly titles/texts) are automatically scaled properly.

@strengejacke
Copy link
Member Author

Example:

library(ggplot2)
library(see)

data(iris)
iris$group4 <- as.factor(sample(1:4, size = nrow(iris), replace = TRUE))
iris$group5 <- as.factor(sample(1:5, size = nrow(iris), replace = TRUE))

d1 <- data.frame(
  x = rep(1:20, 3),
  y = c(
    seq(2, 4, length.out = 20),
    seq(3, 6, length.out = 20),
    seq(5, 3, length.out = 20)
  ),
  group = rep(factor(1:3), each = 20)
)

ggplot(d1, aes(x, y, colour = group)) +
  geom_line(linewidth = 1) +
  scale_color_social() +
  theme_lucid()

ggplot(d1, aes(x, y, colour = group)) +
  geom_line(linewidth = 1) +
  scale_color_social() +
  theme_lucid(base_size = 25)

image

image

@strengejacke
Copy link
Member Author

This is useful if you want to scale plot in RStudio / Positron, to copy it into clipboard and paste it into some office documents, and have proper proportions / scaling of plot elements.

@strengejacke
Copy link
Member Author

@bwiernik WDYT?

Copy link
Contributor

@bwiernik bwiernik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@strengejacke strengejacke merged commit db4a812 into main Jan 31, 2025
22 checks passed
@strengejacke strengejacke deleted the theme_scale branch January 31, 2025 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants