ggalt icon indicating copy to clipboard operation
ggalt copied to clipboard

geom_xspline only works on properly arranged data frames

Open tjebo opened this issue 4 years ago • 0 comments

This behaviour is not really clear from the documentation. It would help to have this information added. (or change the underlying Stat to first arrange by x value.)

Example (partly taken from the documentation example:

library(ggplot2)
library(ggalt)

set.seed(1492)
dat <- data.frame(x=c(1:10, 1:10, 1:10),
                  y=c(sample(15:30, 10), 2*sample(15:30, 10),
                      3*sample(15:30, 10)),
                  group=factor(c(rep(1, 10), rep(2, 10), rep(3, 10)))
)

newdat <- dat[1:10,]

ggplot(newdat, aes(x, y)) +
  geom_point(color="black") +
  geom_xspline(size=0.5)


weirddat <- newdat[sample(nrow(newdat)), ]

ggplot(weirddat, aes(x, y)) +
  geom_point(color="black") +
  geom_xspline(size=0.5)

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

tjebo avatar Jan 01 '21 20:01 tjebo