Skip to content

Improved error messages for plot addition. - #3600

Merged
clauswilke merged 2 commits into
tidyverse:masterfrom
wilkelab:ggplot_add-error-messages
Oct 31, 2019
Merged

clauswilke merged 2 commits into
tidyverse:masterfrom
wilkelab:ggplot_add-error-messages

Conversation

@clauswilke

Copy link
Copy Markdown
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)

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

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

lock Bot commented May 5, 2020

Copy link
Copy Markdown

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