Repository navigation
Add tsggplot(): ggplot2 and plotly versions of tsplot() - #301
Open
TimothyMerlin wants to merge 2 commits into
Open
TimothyMerlin wants to merge 2 commits into
TimothyMerlin wants to merge 2 commits into
Conversation
New exports: - tsggplot(): ggplot2 counterpart of tsplot() for ts, xts and zoo series (monthly, quarterly, yearly, weekly, daily and hourly), with left/right axes (tsr), stacked bars, bands, confidence intervals, highlight windows and fill_year_with_nas. - tsggplotly(): interactive plotly version of a tsggplot() chart, with hover text, a secondary y-axis and the static theme carried over. - init_tsggplot_theme(): theme for both, built on init_tsplot_theme(). Also adds the vignette "tstools with ggplot2", tests for the new functions and helpers, and the NEWS entries. Version is bumped to 0.4.4.9000 for development. New imports: ggplot2, ggnewscale, grid and grDevices; plotly is suggested and only needed for tsggplotly(). Squashed from the development history on TimothyMerlin/tstools (branch tsggplot). Issue numbers in NEWS refer to issues there.
Adds renv.lock, renv/activate.R and an .Rprofile that activates it. renv files are excluded from the package build in .Rbuildignore.
TimothyMerlin
force-pushed
the
tsggplot-upstream
branch
from
October 19, 2026 12:28
b79b122 to
2ab00ef
Compare
TimothyMerlin
marked this pull request as ready for review
October 19, 2026 12:59
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This adds a ggplot2 version of
tsplot()to tstools, along with an interactive plotly version.tsggplot()takes the same inputs astsplot()and uses the same defaults: legends, dual y-axes (tsr), stacked bars withsum_as_line, bands, confidence intervals, highlight windows andfill_year_with_nas. The difference is that it returns a regularggplotobject, so users can add their own layers, scales and themes. It acceptsts,mts,xts,zooand lists of these, at monthly, quarterly, yearly, weekly, daily and hourly frequencies.tsggplotly()turns atsggplot()chart into an interactive Plotly widget. It keeps the static theme and the secondary y-axis, and adds hover text.init_tsggplot_theme()is the theme for both. It is based oninit_tsplot_theme(), so the defaults match.Existing functions are unchanged. The diff to
tsplot.Randimport_helpers.Ronly removes blank lines (from styler).Dependencies
tsggplot()builds and returns a ggplot objecttsggplotly()needs it, and it stops with an install hint when plotly is missingplotly is optional on purpose: it pulls in about 46 packages beyond what ggplot2 needs. ggplot2 itself adds 17 packages to what tstools already installs. We kept it in Imports because the whole point of
tsggplot()is to return a ggplot object. If you would rather keep tstools lighter, we can also move ggplot2 to Suggests or split tsggplot into its own package.Also in this PR
0.4.4.9000.renv.lock,renv/activate.Rand.Rprofile, all excluded from the package build. The lockfile only covers what the package, its tests and its vignette use..gitignore: adds*.pdfand.DS_Store.The feature was developed on TimothyMerlin/tstools (branch
tsggplot) and squashed into one commit here. Issue numbers in NEWS (#4, #14, #16) refer to issues there.Testing
R CMD check --as-crangives no errors, warnings or notes (R 4.6.1, macOS). The CRAN-incoming step was skipped because it needs network access.