Skip to content

Instantly share code, notes, and snippets.

@null712
Last active Aug 29, 2015
Embed
What would you like to do?
pushViewport(viewport(layout = grid.layout(2, 1, heights = unit(c(1,1), "null"))))
theme_set(theme_bw())
plot.both = ggplot(data = data) + geom_line(aes(x = date, y = buy),linetype = 1) +
geom_line(aes(x = date, y = sell),linetype = 3) +
xlab("") + ylab("Weighted Average Price") +
ylim(range(cbind(data$buy, data$sell))[1],range(cbind(data$buy, data$sell))[2]) +
ggtitle(paste(c("ETF ID:", etf.id, " (",etf.sym,")"), collapse = "")) +
theme(
legend.position = "none",
axis.title = element_text(size = 10),
axis.text = element_text(size = 9)
)
plot.spread = ggplot(data = data, aes(x = date, y = spread, colour = ID)) + geom_line() +
xlab("Year 2014") + ylab("Buy-Sell Spread (%)") +
ylim(range(data$spread)[1], range(data$spread)[2]) +
theme(
legend.position = "none",
axis.title = element_text(size = 10),
axis.text = element_text(size = 9)
) +
geom_hline(yintercept = 0, linetype = "dashed")
print(plot.both, vp = viewport(layout.pos.row = 1, layout.pos.col = 1:1))
print(plot.spread, vp = viewport(layout.pos.row = 2, layout.pos.col = 1:1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment