Last active
December 21, 2018 20:00
-
-
Save aarongilman/1c088d93c5ac7d22a5aa0631e46465be to your computer and use it in GitHub Desktop.
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
% U.S. Economic Dashboard Example - December 29, 2016 | |
% Brian W. Dew (brianwdew@gmail.com) | |
\PassOptionsToPackage{table}{xcolor} | |
\documentclass{report} | |
% Packages % | |
\usepackage[right=0.8in, left=0.55in, top=0.7in, bottom=0.9in, headsep=0.15in]{geometry} | |
\usepackage{fancyhdr} | |
\usepackage{titlesec} | |
\titlespacing\section{0pt}{11pt}{3pt} | |
\usepackage{pgfplots, pgfplotstable} | |
\usepackage[eulergreek]{sansmath} | |
\usepackage{xcolor} | |
\usepackage{amssymb} | |
\usepackage{fontawesome} | |
\usepackage[colorlinks, urlcolor=cyan!50!blue]{hyperref} | |
\usepackage{csvsimple} | |
\usetikzlibrary{pgfplots.dateplot, patterns, pgfplots.fillbetween} | |
% Settings % | |
% Sans serif font | |
\renewcommand*\sfdefault{qhv} | |
\renewcommand{\familydefault}{\sfdefault} | |
% Custom chart titles | |
\newcommand{\ct}[2][]{ | |
\noindent \color{cyan!75!blue} \footnotesize $\blacksquare$ | |
\color{black!90}\small \ \ {#1} \hfill | |
\color{cyan!75!blue} \footnotesize $\blacksquare$ \color{black!90}\small \ \ {#2}} | |
% Font Awesome Icon settings | |
\newcommand{\fablueset}[1]{\textcolor{cyan!80!blue}{\large{{#1}}}} | |
% Main style | |
\fancypagestyle{main}{ | |
\headheight = 22pt | |
\fancyhf{} | |
\lhead{\LARGE{\textcolor{cyan!30!blue}{\textbf{Macro and Markets Dashboard:}} | |
United States}} | |
\rhead{\footnotesize \textcolor{cyan!80!blue}{\textbf{Updated:}} \today} | |
\lfoot{\small{\textcolor{cyan!30!blue}{\textbf{Made by:}} IFP Asset Management \ | |
$\vert$ \ assetmanagement@ifpartners.com \ \href{mailto:assetmanagement@ifpartners.com} | |
{\fablueset{\faEnvelope}} \ | |
$\vert$ \ @ifpwm \href{https://twitter.com/ifpwm}{\fablueset{\faTwitter}}}} | |
\cfoot{}} | |
% Custom section titles | |
\titleformat{\section}{\large \bfseries \color{black!60}}{}{0cm} | |
{\color{cyan!80!blue} } | |
% Custom chart footer | |
\newcommand{\cf}[2][]{\indent \color{black!90} \scriptsize{{#1} \hfill {#2}}} | |
% Universal plot settings | |
\pgfplotsset{compat=1.13, max space between ticks=30pt, | |
xticklabel style={align=center}, yticklabel style={align=left}, | |
axis x line*=bottom, every tick/.style={black!20}, | |
every tick label/.append style={black!50,font=\sansmath\sffamily\footnotesize}, | |
x axis line style={black!50}, axis y line=right, y axis line style={opacity=0}, | |
grid style={very thin, black!10}, height=6.8cm, axis line style={draw=none}} | |
\tikzset{every node/.append style={font=\footnotesize}} | |
% Line plot settings | |
\newcommand{\lineplotsettings}{yticklabel style={text width=3em}, | |
ymajorgrids, width=9.5cm, xtick={ | |
{2006-01-01},{2008-01-01},{2010-01-01},{2012-01-01},{2014-01-01},{2016-01-01},{2018-01-01}}, | |
minor xtick={{2007-01-01},{2009-01-01},{2011-01-01},{2013-01-01},{2015-01-01}, {2017-01-01}}, | |
enlarge y limits={0.24}, enlarge x limits={0.03},} | |
% X-Bar plot settings | |
\newcommand{\xbarplotsettings}{xmajorgrids, | |
xbar=0pt, y axis line style={opacity=0}, | |
reverse legend, width=7.4cm, ymajorgrids=false, ytick=data, | |
enlarge x limits={0.14}, tickwidth=0pt, | |
legend style={text=black!70, anchor=north, legend columns=1, draw=none},} | |
%Load bar plot data | |
\pgfplotstableread[header=true, col sep=comma]{data/cpi_comp.csv}\cpi | |
\pgfplotstableread[header=true, col sep=comma]{data/eps.csv}\eps | |
% Solid bars at significant x or y values | |
\newcommand{\bbar}[2]{extra #1 ticks = {{#2}}, | |
extra #1 tick labels = , | |
extra #1 tick style = {grid=major, grid style={thick,solid,black!25}},} | |
% BEGIN DOCUMENT | |
\begin{document} | |
\thispagestyle{main} | |
\section{Economic Growth and Employment} | |
% Title: GDP Growth | |
\ct[Real gross domestic product (GDP) | |
]{Civilian unemployment rate (percent)}\\ | |
% GDP Growth by Component | |
\indent \begin{tikzpicture} | |
\begin{axis}[date coordinates in=x, xticklabel={\year}, stack negative=separate, date ZERO=2006-01-01, | |
legend style={text=black!70, legend columns=2,draw=none, at={(1,0.4)}, | |
/tikz/every even column/.append style={column sep=-0.25cm}}, | |
legend cell align=left, | |
\lineplotsettings | |
\bbar{y}{0} | |
] | |
\addlegendimage{empty legend} | |
\addlegendimage{empty legend} | |
\node[align=left, below, shift=({3.8cm,4.3cm}), fill=white, inner sep=1pt] | |
{(Quarterly percent change, seasonally-adjusted annual rate)}; | |
\addplot[ybar stacked, bar width=2.6pt, color=blue!60!black!90, | |
fill=blue!60!black!90] table [y index = 1, x=DATE, y=GCEC1, col sep=comma] | |
{data/gdp_comp.csv}; | |
\addplot[ybar stacked, bar width=2.6pt, color=yellow!80!orange, | |
fill=yellow!80!orange] table [y index = 2, x=DATE, y=GPDIC1, col sep=comma] | |
{data/gdp_comp.csv}; | |
\addplot[ybar stacked, bar width=2.6pt, draw=cyan!70, fill=cyan!70] | |
table [y index = 3, x=DATE, y=NETEXC, col sep=comma] | |
{data/gdp_comp.csv}; | |
\addplot[ybar stacked, bar width=2.6pt, color=blue!40!green, | |
fill=blue!40!green] table [y index = 4, x=DATE, y=PCECC96, col sep=comma] | |
{data/gdp_comp.csv}; | |
\addplot[thick, color=black] table [x=DATE, y=GDPC1, col sep=comma] | |
{data/gdp_comp.csv} node[pos=0.51,pin=80:{Real GDP Growth}] {}; | |
\node[align=center, below, shift=({2.7cm,-0.25cm})] { | |
\input{data/gdp_comp.txt}}; | |
\legend{Contributions to ,GDP growth, Government, Investment ,Net Exports, Consumption}; | |
\end{axis} | |
\end{tikzpicture}\hspace{1mm} | |
% Unemployment rate | |
\begin{tikzpicture}[trim axis right] | |
\begin{axis}[date coordinates in=x, xticklabel={\year}, \lineplotsettings \bbar{y}{0}] | |
\node[below, shift=({3.2cm,-0.3cm}), fill=white, inner sep=1pt] | |
{\input{data/unemp.txt} unemployed and looking for work}; | |
\addplot[name path=F, thick, no markers, color=red] | |
table [x=DATE, y=LNS14027662, col sep=comma] {data/unemp.csv} | |
node[pos=0.385,pin=270:{College degree}] {}; | |
\addplot[name path=G, thick, no markers, color=red] | |
table [x=DATE, y=LNS14027659, col sep=comma] {data/unemp.csv} | |
node[pos=0.74,pin=90:{No diploma}] {}; | |
\addplot[fill=red!20] | |
fill between[of=F and G]; | |
\addplot[ultra thick, color=black] table [x=DATE, y=UNRATE, col sep=comma] {data/unemp.csv} | |
node[right, pos=0.33, pin={[pin distance=1.4cm]90:{Unemployed and looking for work (U3 rate)}}] {}; | |
\end{axis} | |
\end{tikzpicture} \\ | |
% Footer: CPI | |
\cf[FRED: \href{https://research.stlouisfed.org/fred2/series/GDPC1}{GDPC1}; | |
\href{https://research.stlouisfed.org/fred2/series/GCEC1}{GCEC1}; | |
\href{https://research.stlouisfed.org/fred2/series/GPDIC1}{GPDIC1}; | |
\href{https://research.stlouisfed.org/fred2/series/NETEXC}{NETEXC}; | |
\href{https://research.stlouisfed.org/fred2/series/PCECC96}{PCECC96}] | |
{FRED: \href{https://research.stlouisfed.org/fred2/series/UNRATE}{UNRATE}; | |
\href{https://research.stlouisfed.org/fred2/series/LNS14027659}{LNS14027659}; | |
\href{https://research.stlouisfed.org/fred2/series/LNS14027662}{LNS14027662}} | |
\section{Inflation and Prices} | |
% Title: CPI Components and CPI Growth | |
\ct[Consumer price index (CPI) (annual percent change) | |
]{CPI components (annual percent change)}\\ | |
% Consumer Price Index - All-items and Core CPI line plot | |
\indent \begin{tikzpicture}[trim axis right] | |
\begin{axis}[date coordinates in=x, xticklabel={\year}, \lineplotsettings \bbar{y}{0}] | |
\node[align=left, below, shift=({5.2cm,4.2cm}), fill=white, inner sep=1pt] | |
{5-year expected annual inflation rate: \\ \input{data/breakeven.txt} | |
(FRED: \href{https://fred.stlouisfed.org/series/T5YIFR} | |
{T5YIFR})}; | |
\addplot[ultra thick, color=blue!70] table [x=DATE, y=CPIAUCSL, col sep=comma] | |
{data/cpi.csv} node[pos=0.226,pin=10:{All-items CPI}] {}; | |
\addplot[thick, color=black!50] table [x=DATE, y=CPILFESL, col sep=comma] | |
{data/cpi.csv} node[pos=0.42,pin=275:{Core CPI (excl. food and energy)}] {}; | |
\node[below, shift=({2.9cm,-0.1cm})] {\color{black!80} \input{data/cpi.txt}}; | |
\end{axis} | |
\end{tikzpicture} \hfill | |
% CPI Components | |
\begin{tikzpicture}[trim axis right] | |
\begin{axis}[\xbarplotsettings | |
yticklabel style={align=right, text width=3.3cm, style={black!70}, | |
text height=1.4ex}, width=7cm, | |
bar width=1.3ex, y=3.8ex, axis y line=left, | |
xbar=0pt, | |
y axis line style = { opacity = 0 }, | |
x axis line style = { opacity = 0 }, | |
yticklabel style={align=right, anchor=east}, | |
xmajorticks=false, | |
xmajorgrids=false, | |
ymajorgrids=false, | |
ytick=data, | |
tickwidth = 0pt, | |
enlarge y limits={abs=0.35cm}, | |
every node near coord/.append style={style={black!70}, | |
font=\scriptsize\sffamily\sansmath}, | |
\bbar{x}{0}, legend style={fill=none, at={(0.85,0.22)}}, legend cell align=left, | |
yticklabels from table={\cpi}{Item}] | |
\addplot[nodes near coords, nodes near coords align={horizontal}, fill=cyan!40, | |
draw=cyan,yshift=-0.5pt,] table [y expr=-\coordindex,x index=1] {\cpi}; | |
\addplot[nodes near coords, nodes near coords align={horizontal}, fill=blue!70, | |
draw=blue] table [y expr=-\coordindex, x index=2] {\cpi}; | |
\legend{\scriptsize \input{data/cpi_mo1.txt},\scriptsize \input{data/cpi_mo2.txt}} | |
\end{axis} | |
\end{tikzpicture} \\ | |
% Footer: CPI | |
\cf[All-items: FRED: \href{https://research.stlouisfed.org/fred2/series/CPIAUCSL} | |
{CPIAUCSL}; Core: FRED: | |
\href{https://research.stlouisfed.org/fred2/series/CPILFESL}{CPIFESL} | |
]{FRED: \href{https://research.stlouisfed.org/fred2/categories/9}{CPI Indexes}} | |
\section{Markets, Interest Rates, and Other Indicators} | |
% Title: Earnings per share | |
\ct[S\&P 500 reported earnings per share by industry | |
]{Recent market developments and other key indicators}\\ | |
% Earnings per share | |
\hspace{-10mm}\begin{tikzpicture} | |
\begin{axis}[ | |
stack negative=separate, | |
\xbarplotsettings | |
width=6.9cm, \bbar{x}{0}, legend cell align = left, | |
yticklabel style={ | |
text width=3.2cm, align=right, style={black!70}, text height=1.4ex}, | |
axis y line=left, legend style={at={(0.26,0.7)}}, | |
bar width=1.4ex, y=2.7ex, | |
enlarge y limits={abs=0.3cm}, | |
enlarge x limits={0.04}, | |
nodes near coords=, nodes near coords align={horizontal}, | |
every node near coord/.append style={ | |
font=\scriptsize\sffamily\sansmath, style={black!70}}, | |
yticklabels from table={\eps}{A} | |
] | |
\addplot[xbar stacked, bar shift=0pt, fill=none, draw=none] table [ | |
y expr=-\coordindex, | |
x index=4 | |
] {\eps}; | |
\draw[thick, black!25] | |
({rel axis cs:0,0.02}-|{axis cs:0,0.02}) -- ({rel axis cs:0,1}-|{axis cs:0,0}); | |
\draw[very thin, black!10] | |
({rel axis cs:5,0.02}-|{axis cs:5,0.02}) -- ({rel axis cs:5,1}-|{axis cs:5,0}); | |
\addplot[xbar stacked, bar shift=0pt, fill=orange!70!yellow, draw=orange!70!yellow] | |
table [y expr=-\coordindex, x index=3] {\eps}; | |
\addplot[xbar stacked, bar shift=0pt, fill=orange!70!yellow, draw=orange!70!yellow] | |
table [y expr=-\coordindex, x index=5] {\eps}; | |
\addplot[scatter, only marks, mark=square*, draw=orange!60!red, fill=white] | |
table [y expr=-\coordindex, x index=2] {\eps}; | |
\addplot[scatter, only marks, mark=diamond*, draw=red!60!black, fill=red!60!black] | |
table [y expr=-\coordindex, x index=1] {\eps}; | |
\legend{\scriptsize 5-year range, \scriptsize 1-year average, \scriptsize \input{data/eps.txt}} | |
\end{axis} | |
\end{tikzpicture}\hspace{8mm} | |
% Other key indicators | |
\begin{minipage}[ht!]{.5\linewidth} | |
\vspace{-55mm} | |
\centering | |
\setlength{\tabcolsep}{0.7pt} | |
\scriptsize | |
\color{black!80} | |
\rowcolors{1}{}{black!6} | |
{\renewcommand{\arraystretch}{1.65} | |
\begin{tabular}{l r r r r r r} | |
& & \multicolumn{2}{c}{\normalsize\textsubscript{one month}} & \multicolumn{2}{c}{\normalsize\textsubscript{one year}} & as of:\\ \hline | |
\input{data/table1.txt} | |
\hline | |
\end{tabular}} | |
\end{minipage}% | |
\\ | |
% Footer: EPS and Extras | |
\cf[S\&P Dow Jones Indices: | |
\href{https://us.spindices.com/documents/additional-material/sp-500-eps-est.xlsx} | |
{S\&P 500 growth forecasts (.xls)}] | |
{Retrieved from \href{https://fred.stlouisfed.org/}{FRED}, | |
\href{http://www.cboe.com}{CBOE}, \href{https://www.quandl.com}{Quandl}, and | |
\href{http://www.sca.isr.umich.edu/}{University of Michigan}} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment