I have a csv
file named "aaa.csv" whose content is:
aa,bb,cc
1,1,1
2,2,4
3,3,9
4,4,16
I make plot with the data in this file by pgfplots
. But my code fails to compile. The following message is given:
ERROR: Package pgfplots Error: Sorry, could not retrieve column 'aa'
from table 'aaa.csv'. Please check spelling (or introduce name aliases)..
What's wrong with my code?
MWE:
\documentclass[a4paper]{article}
\usepackage{pgf,pgfplots,pgfplotstable}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
xtick=data,
xticklabels from table={aaa.csv}{aa},
width=.9\textwidth,
title=test,
xlabel={$x$},
ylabel={$y$},
ymin=0,xmin=0,
]
\addplot [red,mark=*,] table[col sep=comma,x=bb,y=cc] {aaa.csv};
\end{axis}
\end{tikzpicture}
\end{document}
Best Answer
You need to tell the plot earlier that your data is using a comma as separator: