Skip to content

We can do better text/label keys now #5561

Closed
@teunbrand

Description

@teunbrand

For both label and text keys, the size of the label aesthetic isn't communicated properly. If the label isn't the default "a", this lets text go out of the bounds of the key area. Moreover, the label keys don't really look like labels as they appear in the plot.

With #5465 in place, we can now assign the appropriate size for label and text keys.

A slightly contrived example to show the issue with the current keys:

devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2

ggplot(mpg, aes(displ, hwy, label = class, colour = class)) +
  geom_text(angle = 45) +
  discrete_scale(
    "label", palette = identity_pal(), super = ScaleDiscreteIdentity
  )

ggplot(mpg, aes(displ, hwy, label = class, colour = class)) +
  geom_label(angle = -45) +
  discrete_scale(
    "label", palette = identity_pal(), super = ScaleDiscreteIdentity
  )

Created on 2023-12-04 with reprex v2.0.2

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