Skip to content

Convert formula to function in sec_axis() #3038

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

Merged
merged 6 commits into from
Apr 13, 2019

Conversation

yutannihilation
Copy link
Member

@yutannihilation yutannihilation commented Dec 14, 2018

Fixes #3031

library(ggplot2)

p <- ggplot(mtcars, aes(cyl, mpg)) +
  geom_point()

# existing notation
p1 <- p + scale_y_continuous(sec.axis = sec_axis(~ . + 10))

# purrr-style notation (might be confusing to use .x for Y axis...)
p2 <- p + scale_y_continuous(sec.axis = sec_axis(~ .x + 10))

# normal function
add_10 <- function(y) y + 10
p3 <- p + scale_y_continuous(sec.axis = sec_axis(add_10))


patchwork::wrap_plots(p1, p2, p3)

Created on 2019-04-13 by the reprex package (v0.2.1)

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.

Can you make a small note in NEWS

@yutannihilation
Copy link
Member Author

Sure.

@yutannihilation yutannihilation changed the title WIP: Convert formula to function in sec_axis() Convert formula to function in sec_axis() Apr 13, 2019
@yutannihilation yutannihilation merged commit 475042e into tidyverse:master Apr 13, 2019
@yutannihilation yutannihilation deleted the formula-as-function branch April 13, 2019 01:41
@lock
Copy link

lock bot commented Oct 10, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Oct 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sec_axis: minor doc + implementation suggestions
2 participants