Splits a time series of exports and imports into segments of trade surplus or deficit, inserting interpolated intersection points where they cross. This allows ribbons to be shaded differently for surplus vs deficit in a balance of trade plot.
StatBalanceOfTradeA data.frame with columns: x, ymin, ymax, direction, and group.
These are passed to a GeomRibbon layer to visualize the balance of trade.
An object of class StatBalanceOfTrade (inherits from Stat, ggproto, gg) of length 4.
A ggplot2::Stat that computes ribbon boundaries for trade balance visualization.
It takes export and import values and generates ymin/ymax pairs for plotting
shaded ribbons showing surplus or deficit. Used internally by geom_balance_of_trade().
geom_balance_of_trade()