Graphics, Figures & Tablesthe requested column number '' in table 'test.csv' does not exist!? Please verify you used the correct index 0 <= i < N

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
FrodoSam
Posts: 3
Joined: Tue Dec 06, 2022 12:00 am

the requested column number '' in table 'test.csv' does not exist!? Please verify you used the correct index 0 <= i < N

Post by FrodoSam »

Hello, I was wondering if someone might be able to help me figure out why this isn't able to plot my test data? I am learning to use pgfplots. I want to make a simple line graph of the data. I made sure to Google for many other posts/forums, but none of their solutions worked for me and I still get the same error.

test.csv contains:

Code: Select all

time,voltage
0,1
1,1.1
2,1.21
3,1.331
4,1.4641
5,1.61051
6,1.771561
7,1.9487171
8,2.14358881
9,2.357947691
10,2.59374246
11,2.853116706
12,3.138428377
13,3.452271214
14,2.934430532
15,2.494265952
16,2.12012606
17,1.802107151
18,1.531791078
19,1.302022416
20,1.106719054
21,0.940711196
22,0.799604516
23,0.679663839
24,0.577714263
25,0.677714263
26,0.777714263
27,0.877714263
28,0.977714263
29,1.077714263
30,1.177714263
31,1.277714263
32,1.377714263
33,1.30882855
34,1.243387122
35,1.181217766
36,1.122156878
37,1.066049034
38,1.012746582
39,0.962109253
40,0.914003791
41,0.868303601
42,0.824888421
43,0.783644
44,0.7444618
45,0.70723871
46,0.671876774
47,0.638282936
48,0.606368789
49,0.57605035
50,0.547247832
51,0.51988544
52,0.493891168
53,0.46919661
54,0.516116271
55,0.567727898
56,0.624500688
57,0.686950757
58,0.755645832
59,0.831210416
60,0.914331457
61,1.005764603
62,1.106341063
63,1.21697517
64,1.338672686
65,1.472539955
66,1.619793951
67,1.781773346
68,1.95995068

\documentclass[conference]{journal}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{pgfplots}
\pgfplotsset{
myplotstyle/.style={
legend style={draw=none, font=\small},
legend cell align=left,
legend pos=north east,
ylabel style={align=center, font=\bfseries\boldmath},
xlabel style={align=center, font=\bfseries\boldmath},
x tick label style={font=\bfseries\boldmath},
y tick label style={font=\bfseries\boldmath},
scaled ticks=false,
every axis plot/.append style={thick},
},
}
\pgfplotsset{compat=1.9}
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\begin{document}

\title{Conference Paper Title}

\maketitle

\begin{abstract}
abstract test
\end{abstract}

\section{test}
abcdefg

\begin{figure}[h!]
\label{figTest}
\begin{tikzpicture}
\begin{axis}[
myplotstyle,
]
\addplot+[] table[x=time,y=voltage, col sep=comma] {test.csv};
\end{axis}
\end{tikzpicture}
\caption{Test Figure}
\end{figure}

\end{document}
Attachments
test.csv
(1.03 KiB) Downloaded 187 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

the requested column number '' in table 'test.csv' does not exist!? Please verify you used the correct index 0 <= i < N

Post by Bartman »

I'd like to repeat my request from your earlier topic to mark your multiline code with the appropriate tags.

Put the \label command after the \caption command.

Your example reduced to the diagram produces neither the error message mentioned nor any other error message.

Code: Select all

\begin{filecontents}{test.csv}
time,voltage
0,1
1,1.1
2,1.21
3,1.331
4,1.4641
5,1.61051
6,1.771561
7,1.9487171
8,2.14358881
9,2.357947691
10,2.59374246
11,2.853116706
12,3.138428377
13,3.452271214
14,2.934430532
15,2.494265952
16,2.12012606
17,1.802107151
18,1.531791078
19,1.302022416
20,1.106719054
21,0.940711196
22,0.799604516
23,0.679663839
24,0.577714263
25,0.677714263
26,0.777714263
27,0.877714263
28,0.977714263
29,1.077714263
30,1.177714263
31,1.277714263
32,1.377714263
33,1.30882855
34,1.243387122
35,1.181217766
36,1.122156878
37,1.066049034
38,1.012746582
39,0.962109253
40,0.914003791
41,0.868303601
42,0.824888421
43,0.783644
44,0.7444618
45,0.70723871
46,0.671876774
47,0.638282936
48,0.606368789
49,0.57605035
50,0.547247832
51,0.51988544
52,0.493891168
53,0.46919661
54,0.516116271
55,0.567727898
56,0.624500688
57,0.686950757
58,0.755645832
59,0.831210416
60,0.914331457
61,1.005764603
62,1.106341063
63,1.21697517
64,1.338672686
65,1.472539955
66,1.619793951
67,1.781773346
68,1.95995068
\end{filecontents}

\documentclass{standalone}
%\usepackage{textcomp}% Search ltnews31 on texdoc.net and read it.
%\usepackage[utf8]{inputenc}% do the same with ltnew28
\usepackage{pgfplots}% loads tikz, that loads graphicx and xcolor

\pgfplotsset{
  compat=1.18,% recent version
  myplotstyle/.style={
    legend style={draw=none, font=\small},
    legend cell align=left,
    legend pos=north east,
    ylabel style={align=center, font=\bfseries\boldmath},
    xlabel style={align=center, font=\bfseries\boldmath},
    x tick label style={font=\bfseries\boldmath},
    y tick label style={font=\bfseries\boldmath},
    scaled ticks=false,
    every axis plot/.append style={thick}
  }
}

\begin{document}
\begin{tikzpicture}
\begin{axis}[myplotstyle]
\addplot+ table[
%  x=time,y=voltage,% correct, but isn't needed
  col sep=comma
] {test.csv};
\end{axis}
\end{tikzpicture}
\end{document}
FrodoSam
Posts: 3
Joined: Tue Dec 06, 2022 12:00 am

the requested column number '' in table 'test.csv' does not exist!? Please verify you used the correct index 0 <= i < N

Post by FrodoSam »

Bartman wrote:I'd like to repeat my request from your earlier topic to mark your multiline code with the appropriate tags.

Put the \label command after the \caption command.

Your example reduced to the diagram produces neither the error message mentioned nor any other error message.

Code: Select all

\begin{filecontents}{test.csv}
time,voltage
0,1
1,1.1
2,1.21
3,1.331
4,1.4641
5,1.61051
6,1.771561
7,1.9487171
8,2.14358881
9,2.357947691
10,2.59374246
11,2.853116706
12,3.138428377
13,3.452271214
14,2.934430532
15,2.494265952
16,2.12012606
17,1.802107151
18,1.531791078
19,1.302022416
20,1.106719054
21,0.940711196
22,0.799604516
23,0.679663839
24,0.577714263
25,0.677714263
26,0.777714263
27,0.877714263
28,0.977714263
29,1.077714263
30,1.177714263
31,1.277714263
32,1.377714263
33,1.30882855
34,1.243387122
35,1.181217766
36,1.122156878
37,1.066049034
38,1.012746582
39,0.962109253
40,0.914003791
41,0.868303601
42,0.824888421
43,0.783644
44,0.7444618
45,0.70723871
46,0.671876774
47,0.638282936
48,0.606368789
49,0.57605035
50,0.547247832
51,0.51988544
52,0.493891168
53,0.46919661
54,0.516116271
55,0.567727898
56,0.624500688
57,0.686950757
58,0.755645832
59,0.831210416
60,0.914331457
61,1.005764603
62,1.106341063
63,1.21697517
64,1.338672686
65,1.472539955
66,1.619793951
67,1.781773346
68,1.95995068
\end{filecontents}

\documentclass{standalone}
%\usepackage{textcomp}% Search ltnews31 on texdoc.net and read it.
%\usepackage[utf8]{inputenc}% do the same with ltnew28
\usepackage{pgfplots}% loads tikz, that loads graphicx and xcolor

\pgfplotsset{
  compat=1.18,% recent version
  myplotstyle/.style={
    legend style={draw=none, font=\small},
    legend cell align=left,
    legend pos=north east,
    ylabel style={align=center, font=\bfseries\boldmath},
    xlabel style={align=center, font=\bfseries\boldmath},
    x tick label style={font=\bfseries\boldmath},
    y tick label style={font=\bfseries\boldmath},
    scaled ticks=false,
    every axis plot/.append style={thick}
  }
}

\begin{document}
\begin{tikzpicture}
\begin{axis}[myplotstyle]
\addplot+ table[
%  x=time,y=voltage,% correct, but isn't needed
  col sep=comma
] {test.csv};
\end{axis}
\end{tikzpicture}
\end{document}
That fixed it! Thank you very much for your help. I put your code into the figure in the journal and it works now. I am having another issue trying to change the color. But, since that is a different issue, I should probably post it as a separate thread. Thank you again for your help.
Post Reply