Skip to content

refactor show.legend code - #3652

Merged
clauswilke merged 3 commits into
tidyverse:masterfrom
wilkelab:show.legend
Dec 6, 2019
Merged

clauswilke merged 3 commits into
tidyverse:masterfrom
wilkelab:show.legend

Conversation

@clauswilke

Copy link
Copy Markdown
Member

Simplifies and unifies the code that the various guides use to determine which layers to include and exclude. This PR came out of this discussion: https://github.com/tidyverse/ggplot2/pull/3646/files#r353483822

@clauswilke

Copy link
Copy Markdown
Member Author

@thomasp85 Could you take a look at this PR, and maybe also the discussion that prompted it (see link above)?

@yutannihilation yutannihilation 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.

Generally looks good. One thing I'm not yet sure is if it's a good idea to stop ensuring show.legend is a logical vector in layer(). Let me think a bit...

Comment thread R/guides-.r Resolved
Comment thread R/guides-.r Resolved
Comment thread R/guide-bins.R Resolved

@yutannihilation yutannihilation 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.

if it's a good idea to stop ensuring show.legend is a logical vector in layer().

Now I come to think this PR does better because show.legend can be modified after layer() anyway so it's good to check it right before actually using it.

(A minor downside is that the warning might be shown multiple times but I think it's acceptable.)

Comment thread R/guides-.r Resolved
@clauswilke

Copy link
Copy Markdown
Member Author

(A minor downside is that the warning might be shown multiple times but I think it's acceptable.)

That's why I'm overwriting show.legend in the layer after issuing the warning. I think this guarantees that there can be only one warning per layer.

https://github.com/clauswilke/ggplot2/blob/82a7c29b2e18a6b34ac8749d4de59764b9eef52a/R/guides-.r#L372-L373

@yutannihilation

Copy link
Copy Markdown
Member

Ah, true. Sorry, I don't know why I didn't read the code comment...

@clauswilke
clauswilke merged commit 16ed4d0 into tidyverse:master Dec 6, 2019
@clauswilke
clauswilke deleted the show.legend branch December 6, 2019 00:59
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.

2 participants