Skip to content

Negative tick strips - #5258

Merged
teunbrand merged 2 commits into
tidyverse:mainfrom
teunbrand:negative_tick_strips
Apr 11, 2023
Merged

teunbrand merged 2 commits into
tidyverse:mainfrom
teunbrand:negative_tick_strips

Conversation

@teunbrand

Copy link
Copy Markdown
Collaborator

This PR aims to fix #5251.

In brief, whether strip padding was necessary depended on whether the size of the axis was 0. With this PR, that now depends on whether there is a relevant axis present. This fixes a problem with axis placement when the axis had acquired 0-size due to missing text and negative tick length (which begets the ticks a 0-size slot in the axis gtable for text alignment reasons).

Although, this example below might 'look' like there should be no padding between axis and strip, this behaviour is consistent with axes with normal dimensions.

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

ggplot(mpg, aes(displ, hwy)) +
  facet_grid("foo" ~ drv, switch = "both") +
  theme(
    strip.placement = "outside",
    axis.ticks.length = unit(-3, "pt"),
    axis.text = element_blank()
  )

Created on 2023-04-03 with reprex v2.0.2

@thomasp85 thomasp85 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@teunbrand
teunbrand merged commit 940658a into tidyverse:main Apr 11, 2023
@teunbrand
teunbrand deleted the negative_tick_strips branch April 11, 2023 16:23
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.

negative axis.ticks.length forces strip.placement to be inside

2 participants