Skip to content

Don't overload x/yevels args with keywords and functions #693

Description

@grantmcdermott

Subititle: Rather use dedicated x/yord arguments.

For some time, we've supported a type-level x/ylevels argument for several types (e.g., type_barplot and type_spineplot). To wit, this takes "a character or numeric vector specifying the ordering of the levels of the x variable (if character) or the corresponding indexes (if numeric) for the plot."

However, during the current v0.8.0 development cycle, I also added type-level xlevels support to type_lines() and type_points(), as a way to fix some layering/alignment inconsistencies between the two (#683). I did this by overloading the argument, so that it also accepted keywords strings (like "asis") and functions.

I originally thought that repurposing (extending) an existing argument was an elegant solution. On reflection, however, I've come to realise that this overloading of x/ylevels is a bad idea. Not only is it brittle, but it isn't very intuitive. I now think we should:

  • revert x/ylevels as originally scoped: i.e., a literal ordering of a variable levels.
  • introduce companion x/yord arguments that derive the order of variables via keywords like "asis" and functions, which apply the appropriate operation on the data. Note that we already have precedent with byord for stacked area plots (Stacked area #688).

These two functions should be mutually exclusive; privilege (the literal) x/ylevels over (the derived) x/yord if both are provided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions