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

Minor break function for log10 ticks #452

Merged
merged 6 commits into from
Oct 21, 2024
Merged

Conversation

teunbrand
Copy link
Contributor

This PR aims to fix tidyverse/ggplot2#6016.

It adds a minor_breaks_log() function that mirrors the calculation in ggplot2::guide_axis_logticks().

By default, it tries to tone down the detailing as we have more powers of 10 covered.
In the example below, the y-axis has ~4 powers and every multiple of a power is marked.
However, in the x-axis spans ~7 powers and only every 5th multiple of a power, and the power itself is marked.

devtools::load_all("~/packages/scales")
#> ℹ Loading scales
library(ggplot2)

ggplot(msleep, aes(bodywt, brainwt)) +
  geom_point() +
  scale_x_log10(minor_breaks = minor_breaks_log()) +
  scale_y_log10(minor_breaks = minor_breaks_log())
#> Warning: Removed 27 rows containing missing values or values outside the scale range
#> (`geom_point()`).

Created on 2024-10-02 with reprex v2.1.1

tests/testthat/test-breaks-log.R Outdated Show resolved Hide resolved
Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

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

Thanks

@thomasp85 thomasp85 merged commit 737eb5c into r-lib:main Oct 21, 2024
12 checks passed
@teunbrand teunbrand deleted the minor_logticks branch October 21, 2024 12:47
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.

guide_axis_logticks() does not coordinate with minor axis breaks?
2 participants