Skip to content

Instantly share code, notes, and snippets.

View AlexB4891's full-sized avatar
🎯
Focusing

Alex Bajaña AlexB4891

🎯
Focusing
View GitHub Profile
@AlexB4891
AlexB4891 / plot_aligned_series.R
Created August 17, 2021 00:53 — forked from tomhopper/plot_aligned_series.R
Align multiple ggplot2 graphs with a common x axis and different y axes, each with different y-axis labels.
#' When plotting multiple data series that share a common x axis but different y axes,
#' we can just plot each graph separately. This suffers from the drawback that the shared axis will typically
#' not align across graphs due to different plot margins.
#' One easy solution is to reshape2::melt() the data and use ggplot2's facet_grid() mapping. However, there is
#' no way to label individual y axes.
#' facet_grid() and facet_wrap() were designed to plot small multiples, where both x- and y-axis ranges are
#' shared acros all plots in the facetting. While the facet_ calls allow us to use different scales with
#' the \code{scales = "free"} argument, they should not be used this way.
#' A more robust approach is to the grid package grid.draw(), rbind() and ggplotGrob() to create a grid of
#' individual plots where the plot axes are properly aligned within the grid.
@AlexB4891
AlexB4891 / tvregression.ipynb
Created May 17, 2020 03:40 — forked from ChadFulton/tvregression.ipynb
Statsmodels state space: time-varying regression
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.