Designing ggtime: a grammar of temporal graphics #79
Replies: 4 comments 18 replies
-
Discussion topic 1: grammar design for temporal alignment A core design element of ggtime is temporal alignment, which can be used to more clearly show seasonal and cyclical patterns. There are three types of alignment in the package design:
The broad question is, where do each of these alignment options belong within ggplot2's layered grammar of graphics? I can justify each of these existing in different places, ranging from Relevant slides: https://slides.mitchelloharawild.com/ggextenders-ggtime/#/section-19 |
Beta Was this translation helpful? Give feedback.
-
Discussion topic 2: calendar coordinate systems I expect this design idea to be the most technically challenging, but the best payoff as an elegant and general solution to the problem. Creating calendars in ggplot2 has been a long-standing challenge that many have taken on to varying extents. @cynthiahqy featured many monolithic calendar plot helpers in this blog https://www.cynthiahqy.com/posts/ggplot-helper-design, and was inspired to try creating one herself https://cynthiahqy.github.io/ggtilecal/. The scope of my calendar ambitions go beyond just plotting tile-based calendars. Instead I want to support arbitrary plot types within a calendar layout, the closest attempt to this is
The proposed I'd appreciate some guidance on gtable and manipulating grobs, because I expect to run into many problems when creating Data handling To arrange the layout of the calendar coordinates, I will need the corresponding classed Perhaps the scale's inverse transformation is suitable here? Since it will necessarily use Grob manipulation To properly cut lines from one row into the next, I think it is safest / best to directly cut and manipulate the grobs during coordinate rendering. One approach to implementing this is to use (or implement) a grob intersection tool, which would allow grobs to be cut arbitrarily based on intersection with a bounding box. Is anyone aware of existing work in set manipulation with grobs, or can suggest alternative methods? Relevant slides: https://slides.mitchelloharawild.com/ggextenders-ggtime/#/section-28 |
Beta Was this translation helpful? Give feedback.
-
Discussion topic 3: wrapping time Wrapping time to produce seasonal plots can be accomplished in many ways. Consider producing polar seasonal plots with this neat hack from @teunbrand: #36 (reply in thread) library(ggplot2)
tsibble::as_tsibble(USAccDeaths) |>
ggplot(aes(
x = lubridate::month(index) + lubridate::year(index) * 12,
y = value,
colour = lubridate::year(index),
group = 1)
) +
geom_line() +
scale_x_continuous(
breaks = scales::breaks_width(1),
limits = c(0, 12), oob = scales::oob_keep
) +
labs(x = "Month", y = "United States accidental deaths", colour = "Year") +
coord_polar()
#> Registered S3 method overwritten by 'tsibble':
#> method from
#> as_tibble.grouped_df dplyr Created on 2024-12-12 with reprex v2.1.1 This works (I think at least) by creating a plot only of the first year, and allowing the rest of the line to be plotted outside of the plot window. However in polar coordinates, the lines wrap around themselves and are overplotted over the previous years. Very tricky, but efficient and would have solved many challenges similar to ggperiodic 😍. Ideally, a similar trick (or less hacky implementation) could be applied to produce season plots in cartesian coordinates. Where instead of running off the end of the plot, it wraps around to the start (or teleports). There are many ways I can imagine this being achieved, including:
Relevant slides: https://slides.mitchelloharawild.com/ggextenders-ggtime/#/section-32 |
Beta Was this translation helpful? Give feedback.
-
Re: interoperability with ggdist: some things that come to mind:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Thanks for joining my extenders presentation about ggtime design! I hope sharing my development-stage design process and hearing from others was insightful, and not too chaotic!
There's clearly a lot of work ahead for implementation, so I really appreciate everyone's design contributions.
I'm hoping for 'measure twice, cut once' for the implementation of this package. 🪚 🤞
I've created response comment threads for each of the presentation's design discussion questions. If you have any thoughts after the talk, we can continue the discussion here 💬
Beta Was this translation helpful? Give feedback.
All reactions