# How to plot data from a CSV file and label axis using tikz and csvsimple?

I use this code

\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot table [x=a, y=c, col sep=comma] {data.csv};
\end{axis}
\end{tikzpicture}
\end{document}


to plot my data

\begin{filecontents*}{data.csv}
year,count
2016,998
2015,1000
2014,900
2013,837
2012,826
2011,784
2010,801
2009,731
2008,703
2007,632
2006,629
2005,516
2004,512
2003,476
2002,444
2001,497
2000,478
1999,400
1998,393
1997,399
1996,387
\end{filecontents*}


First issue conserns the number on the x and y axis is comma separated value, how to fix it, second issue is about axis labeling, how to put the lables?

Here is a working example. Find some knowledge in the manual with the corresponding gallery or around here.

This line \pgfkeys{/pgf/number format/.cd,1000 sep={\,}} lets you adjust the separator (sep option).

The label can be set here \begin{axis}[ xlabel=Count, ylabel=Year].

\documentclass{scrartcl}
\usepackage{tikz,pgfplots}
\usepackage{filecontents}
\begin{document}
\pgfkeys{/pgf/number format/.cd,1000 sep={\,}}
\begin{tikzpicture}
\begin{axis}[ xlabel=Count, ylabel=Year]

\end{axis}
\end{tikzpicture}
\end{document}


this needs to go before the picture line, but for a shorter example I stuck this here:

\begin{filecontents}{data.csv}
year,count
2016,998
2015,1000
2014,900
2013,837
2012,826
2011,784
2010,801
2009,731
2008,703
2007,632
2006,629
2005,516
2004,512
2003,476
2002,444
2001,497
2000,478
1999,400
1998,393
1997,399
1996,387
\end{filecontents}

• In general, don't use the minimal class, article is a better choice: tex.stackexchange.com/questions/42114/… (And pgfplots loads tikz, so you don't need to explicitly load the latter, strictly speaking.) Sep 15 '17 at 22:23