0

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? enter image description here

1
1

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]


\addplot[color=blue,mark=*] table[x=year, y=count, col sep=comma]{data.csv};

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

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.