ggforce icon indicating copy to clipboard operation
ggforce copied to clipboard

Ordering of shapes is changed by `arcPaths`

Open dmurdoch opened this issue 3 years ago • 1 comments

This was reported on StackOverflow here: https://stackoverflow.com/q/66408402/2554330 . The following code plots the circles in the wrong order, so the overlaps look wrong:

library(tidyverse)
library(ggforce)

circles <- data.frame(
    x0 = seq(1, 30),
    y0 = seq(1, 30),
    r = 2
)

ggplot() +
    geom_circle(aes(x0 = x0, y0 = y0, r = r), fill = "grey", data = circles) +
    coord_fixed()

Created on 2021-02-28 by the reprex package (v0.3.0)

The problem is that arcPaths uses base::make.unique() to construct group names for the shapes, and it doesn't preserve the original ordering. I'll submit a PR.

dmurdoch avatar Feb 28 '21 14:02 dmurdoch

This is the same issue as https://github.com/thomasp85/ggraph/issues/199 . I don't know which make_unique implementation is preferable; mine is faster on rep(1, 30), but ggraph:::make_unique is a lot faster on 1:30, and would often give shorter new names.

dmurdoch avatar Feb 28 '21 21:02 dmurdoch