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

docs: how the mode argument works #854

Closed
davidhodge931 opened this issue May 10, 2024 · 0 comments
Closed

docs: how the mode argument works #854

davidhodge931 opened this issue May 10, 2024 · 0 comments

Comments

@davidhodge931
Copy link
Owner

11. A mode argument designed for provided *_mode_* themes

A mode argument has been designed for use with the *_mode_* themes.

With this function, the gg_* function will:

  • add the *_mode_* theme
  • guess the orientation of the plot
  • for "x" orientation plots, remove vertical gridlines and the y axis line/ticks
  • for "y" orientation plots, remove horizontal gridlines, and the x axis line/ticks.

To avoid these side-effects, + the theme on to the output of gg_*. Note there is an orientation argument within the *_mode_* functions that can be useful when used in this way.

penguins2 |>
  gg_pointrange(
    x = species,
    y = flipper_length_mm,
    col = sex,
    stat = "summary",
    subtitle = "\nNo theme side-effects with + theme",
  ) +
  light_mode_n()
p1 <- penguins2 |>
  gg_pointrange(
    x = species,
    y = flipper_length_mm,
    col = sex,
    stat = "summary",
    x_labels = \(x) str_sub(x, 1, 1),
    mode = light_mode_n(),
    subtitle = "Theme side-effects with mode arg",
  ) 

p2 <- penguins2 |>
  gg_pointrange(
    y = species,
    x = flipper_length_mm,
    col = sex,
    stat = "summary",
    x_breaks = breaks_extended(3, only.loose = TRUE),
    y_labels = \(x) str_sub(x, 1, 1),
    mode = light_mode_n(),
  ) 

p1 + p2
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

No branches or pull requests

1 participant