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

Strip clipping optional (re: #4125) #4223

Merged
merged 13 commits into from
Apr 19, 2022
Merged

Conversation

teunbrand
Copy link
Collaborator

@teunbrand teunbrand commented Oct 8, 2020

This should be PR #4125 addressing issue #4118, but I'm clumsy with Github.
I wanted to switch the commits for that PR to a different branch on my fork, but I didn't realise that this would automatically close the old PR. This is the same PR from a different branch.
I'm sorry for the inconvenience.

@thomasp85
Copy link
Member

Late answer to @clauswilke in the original PR... I personally feel that this belongs in themes, but not strongly so. Main motivation is that this seems more about making sure the look fits with the rest of the theme, rather than tweaking data display...

But I can probably be persuaded by some good arguments 🙂

@thomasp85 thomasp85 added this to the ggplot2 3.4.0 milestone Mar 25, 2021
@clauswilke
Copy link
Member

I'm fine with having this as an option in the theme. It just opens the question then of whether the clipping of the plot panel should also be an option in the theme.

@teunbrand
Copy link
Collaborator Author

If it is defined in both places and the default is "inherit", you'd only have to resolve a conflict when a user sets the panel clipping in both places, assuming "on" and "off" overrule "inherit".

@thomasp85
Copy link
Member

We should definitely only have it once. One of the cardinal sins of the current code base is that the same things can be defined and set so many places and we don't want to add to that

@thomasp85
Copy link
Member

I think we can argue that panel clipping is related to how the coordinate system display the data. panel clipping is often data dependent whereas strip clipping is theme dependent (in my mind)

@clauswilke
Copy link
Member

Let's move it into the theme.

@teunbrand
Copy link
Collaborator Author

Would you like me to add panel clipping to the theme in this PR or is it better to postpone changes to panel clipping to a major release as it will likely break people's scripts?

@clauswilke
Copy link
Member

I meant "let's move strip clipping into the theme". I don't think we want to touch panel clipping at this time.

@thomasp85 Does this align with your perspective?

@teunbrand
Copy link
Collaborator Author

I apologise for my misunderstanding. The PR in it's current state has strip clipping in the theme, so I think it might be ready for review. Should I add a test that checks whether clipping can be turned off and on from the theme?

@thomasp85
Copy link
Member

Yep @clauswilke, we agree

@teunbrand I'll give this PR a review once I'm back from vacation

@thomasp85
Copy link
Member

@teunbrand yes, please add a small test

I forgot that this was slated for the feature release, so I'll hold off on reviewing it for now

@markhwhiteii
Copy link

is there an ETA on this feature? I'd like to be able to use it

@teunbrand
Copy link
Collaborator Author

is there an ETA on this feature? I'd like to be able to use it

If you're as impatient as I was, you could for now use this as a proxy. I'm hopeful that this PR will get some consideration before next release ^_^

@markhwhiteii
Copy link

Thank you! I was running into it with theme_void(). I like making transparent figures for decks, so I generally do theme_void() and only add back elements I want. I got around this by doing the opposite: Starting with theme_minimal() and then making the rects all transparent. I don't know why ggsave() was clipping off the bottoms of strip texts for theme_void() but not for theme_minimal().

@teng-gao
Copy link

Any updates on this?

Copy link
Member

@hadley hadley left a comment

Choose a reason for hiding this comment

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

If you merge/rebase and add a news bullet, I think this is probably good to go.

Comment on lines 145 to 151
strip <- render_strips(labels, labeller = label_value,
theme = theme_test() + theme(strip.clip = "on"))
expect_equal(strip$x$top[[1]]$layout$clip, "on")

strip <- render_strips(labels, labeller = label_value,
theme = theme_test() + theme(strip.clip = "off"))
expect_equal(strip$x$top[[1]]$layout$clip, "off")
Copy link
Member

Choose a reason for hiding this comment

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

R/theme.r Outdated
@@ -148,6 +148,9 @@
#' @param strip.placement placement of strip with respect to axes,
#' either "inside" or "outside". Only important when axes and strips are
#' on the same side of the plot.
#' @param strip.clip should strip background edges and strip labels be clipped
#' to the extend of the strip background? Options are `"on"`, `"off"` and
#' `"inherit"`.
Copy link
Member

Choose a reason for hiding this comment

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

What does inherit mean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It means the same thing as for the clip argument in grid::viewport(): it inherits the clipping from the parent viewport. It was suggested to allow this in this comment.

Copy link
Member

Choose a reason for hiding this comment

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

Can you explain that in the docs?

@teunbrand
Copy link
Collaborator Author

Thanks Hadley! I'm a bit busy coming days, but I'll make the changes once I have some extra time.

@teunbrand
Copy link
Collaborator Author

Alright, I think this is about ready :)

@hadley hadley merged commit c151942 into tidyverse:main Apr 19, 2022
@teunbrand teunbrand deleted the stripclip branch April 19, 2022 22:07
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.

6 participants