Open cynthiahqy opened 3 months ago
Possibly needs two 'limits' - one for limits applied to continuous time (what the associated scale expects), and another on wrapped time (what the x-axis is after mapping from cartesian to the calendar coordinate space). This nuance could prove tricky to implement.
There might be some utility in having a time
aesthetic, which defaults to x
if unavailable. It frees up the x
& y
channels for things pie charts for daily data, or side by side columns like:
If we can use the "y"-axis to nest both data & time labels, then why not also the "x"-axis ?
Maybe also some utility in exploring calendar layouts using nested facet for similar reasons (freeing up the x/y channels). Personal data/storytelling scale lends itself to facet solutions, while big data/analytics/modelling lends itself more to coordinate solutions?
Pie charts are a bit trickier than bar charts since there is a conflict in coordinate systems. The layout of pie charts respects a cartesian/calendar coordinate layout in time while the layout of x/y is in polar coordinates. Typical calendars are built on a cartesian coordinate system, and I'm not sure what a calendar built on a polar coordinate system would look like.
An idea for a calendar in polar coordinates could be:
Perhaps this is what a calendar looks like when built upon a polar coordinate system. The y-axis on the coordinate system is comprised within the black bands shown below.
library(ggplot2)
data.frame(
y = 1:120,
x = rep(1:12, 10),
year = rep(2015:2024, each = 12)
) |>
ggplot(aes(x = x, y = y, group = year)) +
geom_line(linewidth = 5) +
coord_polar()
Or altenatively you can transform the calendar y-axis spacing to de-emphasise older observations in time.
data.frame(
y = 1:120,
x = rep(1:12, 10),
year = rep(2015:2024, each = 12)
) |>
ggplot(aes(x = x, y = y, group = year, linewidth = y)) +
geom_line() +
coord_polar() +
scale_linewidth(range = c(1, 10)) +
scale_y_continuous(transform = scales::transform_boxcox(2))
For example…
data.frame(
y = 1:120 + runif(120, -6, 6),
x = rep(1:12, 10),
year = rep(2015:2024, each = 12)
) |>
ggplot(aes(x = x, y = y, group = year)) +
geom_line() +
coord_polar()
data.frame(
y = 11:130 + runif(120, -6, 6),
x = rep(1:12, 10),
year = rep(2015:2024, each = 12)
) |>
ggplot(aes(x = x, y = y, group = year)) +
geom_line() +
coord_polar() +
scale_y_continuous(transform = scales::transform_boxcox(2))
Created on 2024-04-10 with reprex v2.0.2
Use a wrapped cartesian coordinate system to plot temporal data in calendar like layouts instead of calculated variables (e.g. https://github.com/cynthiahqy/ggtilecal)
Should support:
Needs:
lubridate::floor_date()
Gregorian calendarStretch goal -- wrapping non-gregorian calendar layouts:
floor_date_lunar()