Hi! i have to recreate the plot pictured under, but I can't seem to figure out how to do it.
The dataset used can be found her: Real Broad Effective Exchange Rate for Norway | FRED | St. Louis Fed
any help would be greatly appreciated
Hi! i have to recreate the plot pictured under, but I can't seem to figure out how to do it.
The dataset used can be found her: Real Broad Effective Exchange Rate for Norway | FRED | St. Louis Fed
any help would be greatly appreciated
Hi @PatrickJohnsen1 , maybe for start the plot this could help you.
Im download the data, create a new sheet and put in drive:
data <- read_excel("C:\\Users\\MiguelAngel\\Documents\\R Miguelo\\RStudio_Community\\PatrickJohnsen1\\fredgraph.xls",
sheet = "data")
str(data)
data$observationdate <- as.Date(data$observationdate, "%y-%b-%d")
data$observation_date <- as.Date(data$observation_date, "%y-%b-%d")
library(tidyverse)
ggplot(data) +
geom_line(aes(x=observationdate,y=RBNOBIS,
color="Real Broad Effective Exchange Rate for Norway (left)"), size=0.9) +
geom_line(aes(x=observation_date,y=DCOILBRENTEU,
color="Crude Oil Price: Brent-Europe (right)"), size=0.6) +
scale_x_date(date_labels = "%b\n%Y",
date_breaks = "9 month")+
scale_y_continuous(limits = c(10,120),
sec.axis = sec_axis(~ .* 1, name = "DOLLARS PER BARREL"))+
theme(axis.text.x = element_text(size = 8),
panel.background = element_rect(fill = "gray95",
colour = "black",
size = 0.4, linetype = "solid"),
panel.grid.major = element_line(size = 0.5, linetype = 'solid',
colour = "#7F7E7E"),
plot.background = element_rect(fill = "#e0e9f0"),
legend.position = "top",
legend.background = element_rect(colour = "black"),
legend.box.background = element_rect(colour = "black")) +
labs(title="FRED",
x="",
y="INDEX 2010-100") +
scale_color_manual(name = "Data",
values = c("Real Broad Effective Exchange Rate for Norway (left)" = "#4572a7",
"Crude Oil Price: Brent-Europe (right)" = "#aa4643"))
Maybe you need use library(plotly)
for make the interactive plot.
library(plotly)
plot <- ggplot(data) +
geom_line(aes(x=observationdate,y=RBNOBIS,
color="Real Broad Effective Exchange Rate for Norway (left)"), size=0.9) +
geom_line(aes(x=observation_date,y=DCOILBRENTEU,
color="Crude Oil Price: Brent-Europe (right)"), size=0.6) +
scale_x_date(date_labels = "%b\n%Y",
date_breaks = "9 month")+
scale_y_continuous(limits = c(10,120),
sec.axis = sec_axis(~ .* 1, name = "DOLLARS PER BARREL"))+
theme(axis.text.x = element_text(size = 8),
panel.background = element_rect(fill = "gray95",
colour = "black",
size = 0.4, linetype = "solid"),
panel.grid.major = element_line(size = 0.5, linetype = 'solid',
colour = "#7F7E7E"),
plot.background = element_rect(fill = "#e0e9f0"),
legend.position = "top",
legend.background = element_rect(colour = "black"),
legend.box.background = element_rect(colour = "black")) +
labs(title="FRED",
x="",
y="INDEX 2010-100") +
scale_color_manual(name = "Data",
values = c("Real Broad Effective Exchange Rate for Norway (left)" = "#4572a7",
"Crude Oil Price: Brent-Europe (right)" = "#aa4643"))
ggplotly(plot)
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.