Skip to content

Dashed segments cannot align visible endpoints because dash phase is fixed at start #6755

@Hide-Fun

Description

@Hide-Fun

Thanks to the ggplot2 team and community for the great work on this package.

When I draw multiple dashed segments with geom_segment() in ggplot2, segments with different start positions but the same end position have visibly misaligned dash endpoints. It seems the dash pattern is anchored at each segment's start, so the visible ends don't line up even when the end coordinates are identical.

library(ggplot2)
packageVersion("ggplot2")
#> [1] '4.0.0'

df <- data.frame(
  x = c(1, 2, 3),
  x_end = c(4, 4, 4),
  y = c(1, 2, 3)
)

ggplot() +
  geom_segment(
    data = df,
    aes(x = x, y = y , xend = x_end, yend = y),
    linetype = "dashed",
    colour = "steelblue"
  )

Created on 2025-11-25 with reprex v2.1.1

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