2

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
3

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.

output of code

\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.