Skip to content

bad theme error message #3117

Closed
Closed

Description

@topepo

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

Activity

  1. clauswilke commented on Feb 6, 2019

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

  2. self-assigned this
    on Feb 6, 2019
  3. clauswilke commented on May 20, 2022

    @clauswilke
    Member

    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

Metadata

Metadata

Assignees

Labels

themes 💃wip

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions