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

Interpreter/wrapper for gpar() #5867

Merged
merged 4 commits into from
Apr 29, 2024
Merged

Conversation

teunbrand
Copy link
Collaborator

@teunbrand teunbrand commented Apr 26, 2024

This PR aims to fix #5866.

Briefly, a new helper function ggpar() is used to wrap grid::gpar() while applying ggplot's interpretation of graphical parameters.

It simplifies several things:

  • We don't have to protect against 0-length vectors anymore with len0_null().
  • It automatically applies the * .pt modification to lwd.
  • It applies the calculation for point stroke and size via stroke and pointsize arguments.

There are two cases where this isn't used:

  1. When a default argument is an empty gpar().
  2. In sf_grob() which has a mixed interpretations of for example lwd, where in some cases it is linewidth and in other cases it can be stroke.

It is exported but marked as internal function so that extension developers can have access to it as well.

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 teunbrand merged commit 6c2e102 into tidyverse:main Apr 29, 2024
12 checks passed
@teunbrand teunbrand deleted the wrap_gpar branch April 29, 2024 08:34
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.

Standardising calls to gpar()
2 participants