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

Blank text for guide_axis_theta() #5532

Merged
merged 1 commit into from
Nov 27, 2023

Conversation

teunbrand
Copy link
Collaborator

@teunbrand teunbrand commented Nov 21, 2023

This PR aims to fix #5530.

Briefly, it just early-exits when labels are blank and fills NULLs where values are expected.

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

p <- ggplot(mpg, aes(displ, hwy)) +
  geom_point() +
  coord_radial()

p + theme(axis.text = element_blank())

p + theme_void()

Created on 2023-11-21 with reprex v2.0.2

Should I add a test for this?

key <- vec_slice(key, !vec_detect_missing(key$.label %||% NA))

# Early exit if drawing no labels
labels <- key$.label
if (length(labels) < 1) {
return(list(zeroGrob()))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I realised downstream code does not expect a list of grobs, just a single one.

@teunbrand teunbrand added this to the ggplot2 3.5.0 milestone Nov 21, 2023
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.

LGTM

@teunbrand
Copy link
Collaborator Author

Thanks for the review Thomas!

@teunbrand teunbrand merged commit 0a434ea into tidyverse:main Nov 27, 2023
@teunbrand teunbrand deleted the blank_theta_axis_labels branch November 27, 2023 13:26
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.

Bug guide_axis_theta() with blank axis text
2 participants