Last active
October 3, 2022 18:48
-
-
Save charliejhadley/c1ac000116e04de9d9fc591c9487302c to your computer and use it in GitHub Desktop.
mortgate-rate.R
This file contains 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
library(tidyverse) | |
library(lubridate) | |
library(bbplot) | |
library(ggtext) | |
# values for five-year mortgages are inaccurately read from the original graphic by BBC | |
# https://twitter.com/charliejhadley/status/1576992785638772736?s=20&t=DTM3oBSGAsSOQ2SIrvUB-A | |
mortgage_rates <- tribble( | |
~date, ~rate, ~deal, | |
ymd("2021-12-01"), 0.0234, "two-year", | |
ymd("2022-09-23"), 0.0474, "two-year", | |
ymd("2022-10-03"), 0.0575, "two-year", | |
ymd("2021-12-01"), 0.0254, "five-year", | |
ymd("2022-09-23"), 0.0486, "five-year", | |
ymd("2022-10-03"), 0.0545, "five-year", | |
) | |
seq(ymd("2021-12-01"), | |
ymd("2022-10-01"), | |
by = "month") | |
gg_mortgage <- mortgage_rates %>% | |
ggplot() + | |
aes(x = date, | |
y = rate, | |
colour = deal) + | |
geom_line(size = 1.5) + | |
geom_point(size = 3) + | |
scale_x_date( | |
date_labels = "%b %Y", | |
# expand = c(0.2,0), | |
breaks = c(seq(ymd("2021-12-01"), | |
ymd("2022-10-01"), | |
by = "2 month")), | |
limits = c(ymd("2021-11-01"), ymd("2022-10-23")), | |
expand = c(0, 0) | |
) + | |
scale_y_continuous(labels = scales::label_percent(accuracy = 1), | |
limits = c(0, 0.06), | |
n.breaks = 6) + | |
scale_colour_manual(values = c("#FAAB18", "#1380A1")) + | |
labs( | |
title = 'Liz Truss\' government "let\'s fuck about and see" mini-budget radically increased<br>interest rates for both <span style="color:#1380A1;font-weight:bold">two-year fixed</span> and <span style="color:#FAAB18;">five-year fixed</span> mortgages', | |
y = "Interest rate %" | |
) + | |
guides(colour = "none") + | |
bbplot::bbc_style() + | |
theme( | |
plot.title = element_markdown(family = "Helvetica", face = "plain") | |
) | |
gg_mortgage | |
gg_mortgage %>% | |
ggsave("gg_mortgage.png", | |
., | |
width = 15, | |
height = 10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment