Skip to content

Inconsistent setting of lineend in draw_key_* #4653

Closed

Description

@thomasp85

How lineend is set in the draw_key functions does not seem to be standardised and e.g. differs between draw_key_polygon() and draw_key_path(). In general this is not an issue when the linetype is solid as the ends of the lines are not visible, but once the line is non-solid the lineend will be applied to each segment in the line-pattern. This can result in some dramatic visual discrepancies between what is shown in different keys and in the plot itself.

Example of difference in look between plot and legend as well as difference between polygon and path key:

ggplot() + 
  geom_segment(
    aes(x = 0, y = 0:1, xend = 1, yend = 1:0, linetype = c('a', 'b')), 
    size = 1.5, 
    lineend = 'round'
  ) + 
  geom_polygon(
    aes(x = c(0.25, 0.75, 0.5), y = c(0.12, 0.12, 0.88), linetype = 'b'), 
    fill = NA, 
    size = 1.5, 
    colour = 'red'
  ) + 
  scale_linetype_manual(values = c('solid', '11'))

Activity

  1. added
    bugan unexpected problem or unintended behavior
    on Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions