Functions to plot fixedincome objects using ggplot2 package and its grammar of graphics.
# S3 method for class 'SpotRateCurve'
autoplot(
object,
...,
curve.name = NULL,
curve.geom = c("line", "point"),
curve.interpolation = FALSE,
curve.x.axis = c("dates", "terms")
)
# S3 method for class 'SpotRateCurve'
autolayer(
object,
...,
curve.name = NULL,
curve.geom = c("line", "point"),
curve.interpolation = FALSE,
curve.x.axis = c("dates", "terms")
)
# S3 method for class 'ForwardRate'
autolayer(
object,
...,
curve.name = NULL,
curve.geom = c("step", "line", "point"),
curve.x.axis = c("dates", "terms")
)SpotRateCurve or ForwardRate objects
additional arguments passed to ggplot2 geom_* functions
Curve's name
Curve geom used: line, point, step
logical indicating to use curve interpolation in
the plot. Defaults to FALSE.
x axis can be presented with a numeric scale representing
business days (terms) or dates (dates). Defaults to dates.
autoplot() returns a ggplot object with the curve plotted.
autolayer() returns a ggplot2 layer (a LayerInstance object) with the
curve or forward rates, to be added to an existing plot with +.
library(ggplot2)
terms <- c(1, 11, 26, 27, 28)
rates <- c(0.0719, 0.056, 0.0674, 0.0687, 0.07)
curve <- spotratecurve(rates, terms, "discrete", "actual/365", "actual",
refdate = as.Date("2022-02-23")
)
interpolation(curve) <- interp_flatforward()
autoplot(curve, curve.interpolation = TRUE)
autoplot(curve) + autolayer(forwardrate(curve))