suppressPackageStartupMessages({
  library(tidyverse)
  library(fitdistrplus)
  library(PerformanceAnalytics)
})
set.seed(0)

knitr::opts_chunk$set(fig.width = 12, fig.height = 8, fig.retina = TRUE) 
# install.packages("YieldCurve")
# install.packages("Quandl")
library(Quandl)
library(ggplot2)
library(gganimate)
library(tidyverse)
library(ggthemes)
# https://rpubs.com/JanpuHou/327847

Quandl("USTREASURY/YIELD") -> yc
yc %>%
  reshape2::melt("Date") %>%
  as_tibble() %>%
  mutate(date = as.POSIXct(as.character(Date), origin = "1970-01-01")) %>%
  filter(variable %in% c("1 MO", "3 MO", "10 YR", "20 YR", "30 YR")) %>%
  ggplot(aes(x = date, y = value/1e2, colour = variable)) +
  geom_point(size = 0.2) +
  ggtitle("US Tresury Yield Curve") +
  expand_limits(y = 0) +
  scale_x_datetime(date_labels = "%Y", date_breaks = "1 year") +
  scale_y_continuous(labels = scales::percent) +
  xlab("Year") +
  ylab("Yield") +
  ggthemes::scale_color_colorblind(
    name = "Tenure",
    guide = guide_legend(override.aes = list(size = 10))) +
  ggthemes::theme_solarized_2(light = FALSE) +
  theme(axis.text.y = element_text(size = 25),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1, size = 10),
        axis.title = element_text(size = 25, face = "bold"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_line(color = "#262626"))


@statwonk