scattermore
scattermore copied to clipboard
geom for lines
Hi, seems like an amazing library!
I work with massive time series, and I saw in #1 that you have implemented support for lines that work with base plots. I was wondering whether it would be possible to create ggplot geom for it too (like geom_scatterline)?
Hi! yeah that would actually make a total sense (even for the consistency reasons :D ). PR welcome, the main work here is likely to copypaste the other geom code and fill in the line primitives, so actually not very complicated.
I'll try to find time for this soon, but no guarantees unfortunately.
Awesome! I had a go at it for a couple of hours:
scatterlinesare was straightforward to implement. Two current issues:- We'll have to add the extra row in the end to keep the data the same length
- The limits are currently too narrow - so they're not correctly implemented
geom_scatterline: It seems that the RGBW handling is different inscatter_lines_rgbwtthan inscatter_points_rgbwtand it's too late and my brain is too fried to figure it out.
Some work started in #28.
Alright, some examples for what I would expect it to cope with. For references, there could literally be millions of data points in there!
So I guess in the ggplot aes syntax both colour and group would be needed.
By the way, the first one here and the example you provided in another thread (or PR), to match ggplot terminology, those would be geom_paths, because geom_line can only move left to right.
Do you reckon that the new functions would improve rendering of the bottom one which are single lines that aren't actually overlapping anywhere, though of course there are way too many points to be visible?
Can't get the following example to run with reprex, but you could use that - just crank up the n:
library(ggplot2)
library(dplyr)
n <- 100
d <- data.frame(x = seq(from = 0, to = 4*pi, length.out = n))
df <- data.frame()
for (i in 1:5){
df <- d |>
mutate(id = factor(i),
y = sin(x+(i*1.2)) + rnorm(n, sd = 0.2) + i/5) |>
bind_rows(df)
}
ggplot(df, aes(x = x, y = y, colour = id)) +
geom_line()
Ah OK great, that should do it for the examples, thanks!