stefanedwards / lemon

🍋 Lemon --- Freshing up your ggplots
https://cran.r-project.org/package=lemon
GNU General Public License v3.0
180 stars 11 forks source link

geom_pointline has difficulty displaying lines between very close points #7

Closed stefanedwards closed 1 year ago

stefanedwards commented 6 years ago

The issue first appears when rendering the plots. It does not appear to be a rounding error as changing the distance argument to other units affects the outcome.

library(ggplot2)
library(lemon)

data(sunspot.year)
sunspots <- data.frame(count=as.numeric(sunspot.year), year=seq.int(start(sunspot.year)[1], end(sunspot.year)[1]))
sunspots <- subset(sunspots, year > 1900)

ggplot(sunspots, aes(x=year, y=count)) + geom_pointline(distance=unit(3, 'pt')) + labs(main='geom_pointline')
pointline

small big

It can as best be described that if the offset 'connector point' of a point extends past the corresponding 'connector point' in the connecting point, in either horisontal or vertical distance, this appears. But determining whether this is the case is difficult because comparisons of unit cannot be done.