How do I plot economic type data that has a time series element from a CSV? For example:
Date GDP
2009 6
2010 3
2011 4
2012 7
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityHow do I plot economic type data that has a time series element from a CSV? For example:
Date GDP
2009 6
2010 3
2011 4
2012 7
See for example section 3.3 in the pgfplots
manual.
There are a lot of of examples in the manual, so it's not just a handy reference, sometimes scrolling through it looking at examples can be a way of finding answers.
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=This,
ylabel=That,
% remove comma in xticklabels
xticklabel style={/pgf/number format/set thousands separator={}},
% one tick every year
xtick distance=1
]
\addplot table {
Date GDP
2009 6
2010 3
2011 4
2012 7
};
% if you have the file, you can do
% \addplot table {datafile.csv};
\end{axis}
\end{tikzpicture}
\end{document}