Skip to content

bad theme error message #3117

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

Closed
topepo opened this issue Feb 6, 2019 · 2 comments · Fixed by #5252
Closed

bad theme error message #3117

topepo opened this issue Feb 6, 2019 · 2 comments · Fixed by #5252
Assignees
Labels
themes 💃 wip work in progress

Comments

@topepo
Copy link
Member

topepo commented Feb 6, 2019

We issue a clear warning below but new users may not understand the severity. A better error message when rendering the plot would be an improvement

library(ggplot2)

# missing ()
theme_set(theme_bw)
#> Warning: New theme missing the following elements: line,
#> rect, text, axis.title.x, axis.title.x.top, axis.title.y,
#> axis.title.y.right, axis.text, axis.text.x, axis.text.x.top,
#> axis.text.y, axis.text.y.right, axis.ticks, axis.ticks.length,
#> axis.line, axis.line.x, axis.line.y, legend.background, legend.margin,
#> legend.spacing, legend.spacing.x, legend.spacing.y, legend.key,
#> legend.key.size, legend.key.height, legend.key.width, legend.text,
#> legend.text.align, legend.title, legend.title.align, legend.position,
#> legend.direction, legend.justification, legend.box, legend.box.margin,
#> legend.box.background, legend.box.spacing, panel.background,
#> panel.border, panel.spacing, panel.spacing.x, panel.spacing.y,
#> panel.grid, panel.grid.minor, panel.ontop, plot.background, plot.title,
#> plot.subtitle, plot.caption, plot.tag, plot.tag.position, plot.margin,
#> strip.background, strip.placement, strip.text, strip.text.x, strip.text.y,
#> strip.switch.pad.grid, strip.switch.pad.wrap

ggplot(mtcars)
#> Error in y[setdiff(names(y), names(x))]: object of type 'closure' is not subsettable

Created on 2019-02-06 by the reprex
package
(v0.2.0).

@clauswilke
Copy link
Member

I'm in the process of rewriting how themes are set, combined, and processed (#2784), so it'll probably make sense to fix this issue in that rewrite.

@clauswilke clauswilke self-assigned this Feb 6, 2019
@paleolimbot paleolimbot added themes 💃 wip work in progress labels May 22, 2019
@clauswilke
Copy link
Member

clauswilke commented May 20, 2022

The error is now different. At least it points to a problem with themes. Not sure if it can be improved further.

library(ggplot2)
theme_set(theme_bw)
ggplot(mtcars)
#> Error in default + theme: non-numeric argument to binary operator

Created on 2022-05-20 by the reprex package (v2.0.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
themes 💃 wip work in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants