Skip to content

Docs for discrete_scale inaccurate #2052

Closed
@alistaire47

Description

@alistaire47

In the documentation for ?discrete_scale, the labels parameter is documented as

NULL for no labels, waiver() for default labels (labels the same as breaks), a character vector the same length as breaks, or a named character vector whose names are used to match replacement the labels for matching breaks.

However, in ?scale_x_discrete, the final example shows a very important alternative: passing a function as a formatter:

# Use abbreviate as a formatter to reduce long names
ggplot(mpg, aes(reorder(manufacturer, displ), cty)) +
  geom_point() +
  scale_x_discrete(labels = abbreviate)

and thus should probably be documented more like continuous_scale's labels parameter:

One of:

  • NULL for no labels
  • waiver() for the default labels computed by the transformation object
  • A character vector giving labels (must be same length as breaks)
  • A function that takes the breaks as input and returns labels as output

I'm happy to assemble a quick PR if you like, but will everything get redone in the course of dealing with #1750 anyway?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions