Thanks for your reply @rensa. So, I put an example that sort of demonstrate what I'd like to achieve. Please check my implementation of geom_sand and stat_sand in this GitHub Gist. As you can see, I'm following the standard procedure, and I'd like to write a ggextension where I can draw some custom GeomSegment alongside the points that I'm drawing. So, the following code will produce the shown plot.
df <- data.frame(x = runif(10, 0, 10), y = runif(10, 0, 10))
ggplot(df, aes(x = x, y = y)) +
geom_sand(hl = 5, vl = 5)
I have a few questions regarding my implementation.
- Do I follow the right protocol for implementing what I'd like to achieve? In some cases, I'd like to adjust and calculate other lines based on the given data on my
stat_sand
- What if I would like to change the
x and y ranges and limits?
- What if I would like to change some parameters like
axis.ticks or panel.grid.major.x and panel.grid.minor.x? _These are theme() parameters that I can change easily on ggplot() but I'm not sure how to properly change then in the ggextension.
- If I use
compute_panel— as I realized sometimes I have more control when using compute_panel — will ggplot be able to apply my geom_* and stat_* on groups or facets?
I've tried to summarize everything, I hope I'm being clear here, if not, please let me know. In the meanwhile, I'm trying to google things but unfortunately, there is not a lot on the internet on developing ggextensions. I read some codes too but I see that everyone has implemented their own hack for each of these problems, and I cannot find examples where people adjust the range and axis.ticks.
Thanks in advance for your help,
Amir.