Skip to content

Solid arrows with segments that are not solid have visual artifacts #6749

@malcolmbarrett

Description

@malcolmbarrett

Someone reported an issue in ggdag with dashed arrows with solid arrowheads (r-causal/ggdag#216). I checked both ggplot2 and ggraph, and it seems like this may be an issue in ggplot2.

Creating a dashed line with a solid arrowhead results in visual artifacts. It looks like the dashed line might ALSO have an arrowhead behind it

library(ggplot2)
library(grid)

df <- data.frame(
  x = c(0, 0),
  y = c(0, 0.5),
  xend = c(1, 1),
  yend = c(0, 0.5),
  linetype = c("solid", "dashed")
)

ggplot(df) +
  geom_segment(
    aes(x, y, xend = xend, yend = yend, linetype = linetype),
    linewidth = 1,
    arrow = arrow(length = unit(0.3, "cm"), type = "closed")
  ) +
  coord_fixed(xlim = c(-0.1, 1.1), ylim = c(-0.2, 0.9)) +
  scale_linetype_identity() +
  theme_void()

Created on 2025-11-17 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