Skip to content

legend.key.spacing change the distance between the key and the label #6366

Open
@Breeze-Hu

Description

@Breeze-Hu

Hi!
Currently ggplot provides identity-detailed options for adjusting the properties of each element of the legend. The following options for legend.key.spacing{x/y}, which adjusts the distance of each mini group, and legend.text both work as expected.
ggplot2 3.5.0: Legends - Spacing and margins

(p <- ggplot(mpg, aes(displ, hwy, colour = class)) +
  geom_point() +
  guides(colour = guide_legend(ncol = 2)) 
)

p+  
  theme(
    legend.key.spacing.x = unit(20, "pt"))
Image

But I have a doubt about the legend.key.spacing:

p+
  theme(legend.key.spacing = unit(20, "pt"))
Image

From the result, it looks like the key and label spacing has changed. As legend.text = element_text (margin = margin (l = ...)) has been changed.

Should the distance between key and label change when using legend.key.spacing? I'm not quite sure if this is an intentional feature or a bug.

Best wishes,
Hu

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions