Skip to content

Conversation

@jack-davison
Copy link
Collaborator

@jack-davison jack-davison commented Dec 9, 2025

This PR implements ggplot2 versions of 'time series and trends' functions, as part of the drive to provide a modern API for openair.

Tracking implementation:

  • trendLevel() -> plot_heatmap()
  • calendarPlot() -> plot_calendar()
  • timeProp() -> plot_trend_bars()
  • timePlot() -> plot_trend_lines()
  • smoothTrend() -> plot_trend_smooth()
  • TheilSen() -> plot_trend_theilsen()
  • timeVariation() -> plot_variation()

This PR also adds some necessary structural changes to initialise ggplot2 in openair:

  • Adds ggplot2 (>=4.0.0) and scales as dependencies.
  • Adds exported "options" functions to help manage options in a consistent way:
    • discretise_opts for flexibly discretising a scale (e.g., plot_calendar, plot_heatmap)
    • facet_opts for controlling how facets are handled
    • (soon) windflow_opts for controlling the appearance of windflows
  • Adds internal functions:
    • facet_wd() for wind direction faceting. I think this could be exported one day.
    • layer_windflow() for adding 'windflow' arrows (e.g., in plot_calendar, plot_trend_line)

Old functions are still present, and documentation cross-links them.

There are a few initial benefits to the ggplot2 functions:

  • ggplot2 handles a lot of things better than lattice, meaning the functions are a lot shorter.
  • It is much easier to have type be 2 things and create a grid.
  • There are some initial 'easy wins' - e.g., adding windflow to plot_heatmap() (which fixes a very old issue - [Feature request]: wind vectors in trendlevel() #49)

Some Examples:

image image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants