Skip to content

Improved error messages for plot addition. #3600

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 2 commits into from
Oct 31, 2019

Conversation

clauswilke
Copy link
Member

I made a few improvements to the error messages when plot addition fails, based on recommendations in the tidyverse style guide and also based on feedback from this Twitter thread: https://twitter.com/ClausWilke/status/1189725947508989953?s=20

library(ggplot2)

ggplot() + 1
#> Error: Can't add `1` to a ggplot object.

ggplot() + geom_point
#> Error: Can't add `geom_point` to a ggplot object.
#> Did you forget to add parentheses, as in `geom_point()`?

Created on 2019-10-30 by the reprex package (v0.3.0)

Copy link
Member

@yutannihilation yutannihilation left a comment

Choose a reason for hiding this comment

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

Looks good. I personally liked the simpleness of "Did you mean," but, looking at your Twitter thread, it seems better to hint about parentheses explicitly.

@clauswilke clauswilke merged commit fb73191 into tidyverse:master Oct 31, 2019
@clauswilke clauswilke deleted the ggplot_add-error-messages branch October 31, 2019 15:08
@lock
Copy link

lock bot commented May 5, 2020

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 May 5, 2020
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.

2 participants