Plotting a 3D data-set from a .csv file
up vote
3
down vote
favorite
I have a .csv
with 2-dimensional data. Now I am trying to plot it in different index ranging from -n:1:n
(this index is y-axis
).
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
pgfplotsset{width=7cm,compat=1.8}
usepackage{pgfplotstable}
begin{document}
begin{tikzpicture}
pgfplotstableread{
T3,v11
0,0.66582
0.000125,0.66582
0.00025,0.66582
0.000375,0.66582
0.0005,0.66582
0.000625,0.66582
0.00075,0.66582
0.000875,0.66582
0.001,0.66582
0.001125,0.66582
}dummydata
begin{axis}[
domain=-4:4,
samples y=0, ytick={1,...,4},
]
{
addplot3 table [x =T3, y expr=1, z=v11, col sep = comma]
{dummydata};
}
end{axis}
end{tikzpicture}
end{document}
This throws errors like:
! Package pgfplots Error: The requested list entry with index 1 of
dummydata i s too large; this list has not enough elements..
See the pgfplots package documentation for explanation. Type H
for immediate help. ...
l.27 {dummydata};
This error message was generated by an errmessage command, so I can't give any explicit help. Pretend that
you're Hercule Poirot: Examine all clues, and deduce the truth by
order and method.
! Package pgfplots Error: Sorry, could not retrieve column 'T3' from
table ''. Please check spelling (or introduce name
aliases)..
See the pgfplots package documentation for explanation. Type H
for immediate help. ...
l.27 {dummydata};
(That was another errmessage.)
! Package pgfplots Error: Sorry, could not retrieve column 'v11' from
table ''. Please check spelling (or introduce name
aliases)..
See the pgfplots package documentation for explanation. Type H
for immediate help. ...
l.27 {dummydata};
(That was another errmessage.)
Package pgfplots Warning: the current plot has no coordinates (or all
have been filtered away) on input line 27.
[warning /pgfplots/warning/plot without coordinates]
Package pgfplots Warning: You have an axis with empty range (in
direction z). R eplacing it with a default range and clearing all
plots. on input line 29.
[warning /pgfplots/warning/empty range cleared axis] LaTeX Font Info:
External fontcmex10' loaded for size (Font) <7> on
cmex10' loaded for
input line 29. LaTeX Font Info: External font
size (Font) <5> on input line 29.
However, instead of using a .csv
format, if I stick with a table format (that is removing a comma between the data and also col sep = comma
in the plot, then I get what I desired. However, the data I have is in .csv
format (pretty big). So, instead of creating a huge data-set for y-axis
, how can I achieve it with the above-mentioned script.
The one that works without a .csv
format (and without creating a huge data-set for a different axis per-se):
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
pgfplotsset{width=7cm,compat=1.8}
usepackage{pgfplotstable}
begin{document}
begin{tikzpicture}
pgfplotstableread{
T3 v11
0 0.66582
0.000125 0.66582
0.00025 0.66582
0.000375 0.66582
0.0005 0.66582
0.000625 0.66582
0.00075 0.66582
0.000875 0.66582
0.001 0.66582
0.001125 0.66582
}dummydata
begin{axis}[
domain=-4:4,
samples y=0, ytick={1,...,4},
]
{
addplot3 table [x =T3, y expr=1, z=v11]
{dummydata};
}
end{axis}
end{tikzpicture}
end{document}
which would give me the desired output:
PS: This is just an example, in reality I use the external file to import my data for plotting purposes.
tikz-pgf pgfplots pgfplotstable
add a comment |
up vote
3
down vote
favorite
I have a .csv
with 2-dimensional data. Now I am trying to plot it in different index ranging from -n:1:n
(this index is y-axis
).
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
pgfplotsset{width=7cm,compat=1.8}
usepackage{pgfplotstable}
begin{document}
begin{tikzpicture}
pgfplotstableread{
T3,v11
0,0.66582
0.000125,0.66582
0.00025,0.66582
0.000375,0.66582
0.0005,0.66582
0.000625,0.66582
0.00075,0.66582
0.000875,0.66582
0.001,0.66582
0.001125,0.66582
}dummydata
begin{axis}[
domain=-4:4,
samples y=0, ytick={1,...,4},
]
{
addplot3 table [x =T3, y expr=1, z=v11, col sep = comma]
{dummydata};
}
end{axis}
end{tikzpicture}
end{document}
This throws errors like:
! Package pgfplots Error: The requested list entry with index 1 of
dummydata i s too large; this list has not enough elements..
See the pgfplots package documentation for explanation. Type H
for immediate help. ...
l.27 {dummydata};
This error message was generated by an errmessage command, so I can't give any explicit help. Pretend that
you're Hercule Poirot: Examine all clues, and deduce the truth by
order and method.
! Package pgfplots Error: Sorry, could not retrieve column 'T3' from
table ''. Please check spelling (or introduce name
aliases)..
See the pgfplots package documentation for explanation. Type H
for immediate help. ...
l.27 {dummydata};
(That was another errmessage.)
! Package pgfplots Error: Sorry, could not retrieve column 'v11' from
table ''. Please check spelling (or introduce name
aliases)..
See the pgfplots package documentation for explanation. Type H
for immediate help. ...
l.27 {dummydata};
(That was another errmessage.)
Package pgfplots Warning: the current plot has no coordinates (or all
have been filtered away) on input line 27.
[warning /pgfplots/warning/plot without coordinates]
Package pgfplots Warning: You have an axis with empty range (in
direction z). R eplacing it with a default range and clearing all
plots. on input line 29.
[warning /pgfplots/warning/empty range cleared axis] LaTeX Font Info:
External fontcmex10' loaded for size (Font) <7> on
cmex10' loaded for
input line 29. LaTeX Font Info: External font
size (Font) <5> on input line 29.
However, instead of using a .csv
format, if I stick with a table format (that is removing a comma between the data and also col sep = comma
in the plot, then I get what I desired. However, the data I have is in .csv
format (pretty big). So, instead of creating a huge data-set for y-axis
, how can I achieve it with the above-mentioned script.
The one that works without a .csv
format (and without creating a huge data-set for a different axis per-se):
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
pgfplotsset{width=7cm,compat=1.8}
usepackage{pgfplotstable}
begin{document}
begin{tikzpicture}
pgfplotstableread{
T3 v11
0 0.66582
0.000125 0.66582
0.00025 0.66582
0.000375 0.66582
0.0005 0.66582
0.000625 0.66582
0.00075 0.66582
0.000875 0.66582
0.001 0.66582
0.001125 0.66582
}dummydata
begin{axis}[
domain=-4:4,
samples y=0, ytick={1,...,4},
]
{
addplot3 table [x =T3, y expr=1, z=v11]
{dummydata};
}
end{axis}
end{tikzpicture}
end{document}
which would give me the desired output:
PS: This is just an example, in reality I use the external file to import my data for plotting purposes.
tikz-pgf pgfplots pgfplotstable
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I have a .csv
with 2-dimensional data. Now I am trying to plot it in different index ranging from -n:1:n
(this index is y-axis
).
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
pgfplotsset{width=7cm,compat=1.8}
usepackage{pgfplotstable}
begin{document}
begin{tikzpicture}
pgfplotstableread{
T3,v11
0,0.66582
0.000125,0.66582
0.00025,0.66582
0.000375,0.66582
0.0005,0.66582
0.000625,0.66582
0.00075,0.66582
0.000875,0.66582
0.001,0.66582
0.001125,0.66582
}dummydata
begin{axis}[
domain=-4:4,
samples y=0, ytick={1,...,4},
]
{
addplot3 table [x =T3, y expr=1, z=v11, col sep = comma]
{dummydata};
}
end{axis}
end{tikzpicture}
end{document}
This throws errors like:
! Package pgfplots Error: The requested list entry with index 1 of
dummydata i s too large; this list has not enough elements..
See the pgfplots package documentation for explanation. Type H
for immediate help. ...
l.27 {dummydata};
This error message was generated by an errmessage command, so I can't give any explicit help. Pretend that
you're Hercule Poirot: Examine all clues, and deduce the truth by
order and method.
! Package pgfplots Error: Sorry, could not retrieve column 'T3' from
table ''. Please check spelling (or introduce name
aliases)..
See the pgfplots package documentation for explanation. Type H
for immediate help. ...
l.27 {dummydata};
(That was another errmessage.)
! Package pgfplots Error: Sorry, could not retrieve column 'v11' from
table ''. Please check spelling (or introduce name
aliases)..
See the pgfplots package documentation for explanation. Type H
for immediate help. ...
l.27 {dummydata};
(That was another errmessage.)
Package pgfplots Warning: the current plot has no coordinates (or all
have been filtered away) on input line 27.
[warning /pgfplots/warning/plot without coordinates]
Package pgfplots Warning: You have an axis with empty range (in
direction z). R eplacing it with a default range and clearing all
plots. on input line 29.
[warning /pgfplots/warning/empty range cleared axis] LaTeX Font Info:
External fontcmex10' loaded for size (Font) <7> on
cmex10' loaded for
input line 29. LaTeX Font Info: External font
size (Font) <5> on input line 29.
However, instead of using a .csv
format, if I stick with a table format (that is removing a comma between the data and also col sep = comma
in the plot, then I get what I desired. However, the data I have is in .csv
format (pretty big). So, instead of creating a huge data-set for y-axis
, how can I achieve it with the above-mentioned script.
The one that works without a .csv
format (and without creating a huge data-set for a different axis per-se):
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
pgfplotsset{width=7cm,compat=1.8}
usepackage{pgfplotstable}
begin{document}
begin{tikzpicture}
pgfplotstableread{
T3 v11
0 0.66582
0.000125 0.66582
0.00025 0.66582
0.000375 0.66582
0.0005 0.66582
0.000625 0.66582
0.00075 0.66582
0.000875 0.66582
0.001 0.66582
0.001125 0.66582
}dummydata
begin{axis}[
domain=-4:4,
samples y=0, ytick={1,...,4},
]
{
addplot3 table [x =T3, y expr=1, z=v11]
{dummydata};
}
end{axis}
end{tikzpicture}
end{document}
which would give me the desired output:
PS: This is just an example, in reality I use the external file to import my data for plotting purposes.
tikz-pgf pgfplots pgfplotstable
I have a .csv
with 2-dimensional data. Now I am trying to plot it in different index ranging from -n:1:n
(this index is y-axis
).
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
pgfplotsset{width=7cm,compat=1.8}
usepackage{pgfplotstable}
begin{document}
begin{tikzpicture}
pgfplotstableread{
T3,v11
0,0.66582
0.000125,0.66582
0.00025,0.66582
0.000375,0.66582
0.0005,0.66582
0.000625,0.66582
0.00075,0.66582
0.000875,0.66582
0.001,0.66582
0.001125,0.66582
}dummydata
begin{axis}[
domain=-4:4,
samples y=0, ytick={1,...,4},
]
{
addplot3 table [x =T3, y expr=1, z=v11, col sep = comma]
{dummydata};
}
end{axis}
end{tikzpicture}
end{document}
This throws errors like:
! Package pgfplots Error: The requested list entry with index 1 of
dummydata i s too large; this list has not enough elements..
See the pgfplots package documentation for explanation. Type H
for immediate help. ...
l.27 {dummydata};
This error message was generated by an errmessage command, so I can't give any explicit help. Pretend that
you're Hercule Poirot: Examine all clues, and deduce the truth by
order and method.
! Package pgfplots Error: Sorry, could not retrieve column 'T3' from
table ''. Please check spelling (or introduce name
aliases)..
See the pgfplots package documentation for explanation. Type H
for immediate help. ...
l.27 {dummydata};
(That was another errmessage.)
! Package pgfplots Error: Sorry, could not retrieve column 'v11' from
table ''. Please check spelling (or introduce name
aliases)..
See the pgfplots package documentation for explanation. Type H
for immediate help. ...
l.27 {dummydata};
(That was another errmessage.)
Package pgfplots Warning: the current plot has no coordinates (or all
have been filtered away) on input line 27.
[warning /pgfplots/warning/plot without coordinates]
Package pgfplots Warning: You have an axis with empty range (in
direction z). R eplacing it with a default range and clearing all
plots. on input line 29.
[warning /pgfplots/warning/empty range cleared axis] LaTeX Font Info:
External fontcmex10' loaded for size (Font) <7> on
cmex10' loaded for
input line 29. LaTeX Font Info: External font
size (Font) <5> on input line 29.
However, instead of using a .csv
format, if I stick with a table format (that is removing a comma between the data and also col sep = comma
in the plot, then I get what I desired. However, the data I have is in .csv
format (pretty big). So, instead of creating a huge data-set for y-axis
, how can I achieve it with the above-mentioned script.
The one that works without a .csv
format (and without creating a huge data-set for a different axis per-se):
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
pgfplotsset{width=7cm,compat=1.8}
usepackage{pgfplotstable}
begin{document}
begin{tikzpicture}
pgfplotstableread{
T3 v11
0 0.66582
0.000125 0.66582
0.00025 0.66582
0.000375 0.66582
0.0005 0.66582
0.000625 0.66582
0.00075 0.66582
0.000875 0.66582
0.001 0.66582
0.001125 0.66582
}dummydata
begin{axis}[
domain=-4:4,
samples y=0, ytick={1,...,4},
]
{
addplot3 table [x =T3, y expr=1, z=v11]
{dummydata};
}
end{axis}
end{tikzpicture}
end{document}
which would give me the desired output:
PS: This is just an example, in reality I use the external file to import my data for plotting purposes.
tikz-pgf pgfplots pgfplotstable
tikz-pgf pgfplots pgfplotstable
edited 2 days ago
asked 2 days ago
Raaja
2,0062523
2,0062523
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
5
down vote
accepted
After moving col sep=comma
to the right place, the errors are gone.
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
pgfplotsset{width=7cm,compat=1.8}
usepackage{pgfplotstable}
begin{document}
begin{tikzpicture}
pgfplotstableread[col sep = comma]{
T3,v11
0,0.66582
0.000125,0.66582
0.00025,0.66582
0.000375,0.66582
0.0005,0.66582
0.000625,0.66582
0.00075,0.66582
0.000875,0.66582
0.001,0.66582
0.001125,0.66582
}dummydata
begin{axis}[
domain=-4:4,
samples y=0, ytick={1,...,4},
]
{
addplot3 table [x =T3, y expr=1, z=v11]
{dummydata};
}
end{axis}
end{tikzpicture}
end{document}
MINI-EXPLANATION: When you load the data, you need to tell pgfplots
what the structure of the file is, i.e. how it is supposed to decompose it into rows and columns, i.e. cells. If you do not tell pgfplots
that the columns are separated by commas, say, it will assume they are separated by spaces or tabs, which is why your second example worked. In your first example, pgfplots
"thought" the first non-header row has only the cell 0,0.66582
rather than two cells 0
and 0.66582
, and so on, which explains the error messages. And yes, I can see how this might be confusing, after all you specify only in the plot which column goes where.
Nice answer, could you briefly explain why we must do that change?
– Raaja
2 days ago
1
@Raaja I added some mini-explanation.
– marmot
2 days ago
1
Thanks for the little brief, its clear for me now!
– Raaja
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
After moving col sep=comma
to the right place, the errors are gone.
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
pgfplotsset{width=7cm,compat=1.8}
usepackage{pgfplotstable}
begin{document}
begin{tikzpicture}
pgfplotstableread[col sep = comma]{
T3,v11
0,0.66582
0.000125,0.66582
0.00025,0.66582
0.000375,0.66582
0.0005,0.66582
0.000625,0.66582
0.00075,0.66582
0.000875,0.66582
0.001,0.66582
0.001125,0.66582
}dummydata
begin{axis}[
domain=-4:4,
samples y=0, ytick={1,...,4},
]
{
addplot3 table [x =T3, y expr=1, z=v11]
{dummydata};
}
end{axis}
end{tikzpicture}
end{document}
MINI-EXPLANATION: When you load the data, you need to tell pgfplots
what the structure of the file is, i.e. how it is supposed to decompose it into rows and columns, i.e. cells. If you do not tell pgfplots
that the columns are separated by commas, say, it will assume they are separated by spaces or tabs, which is why your second example worked. In your first example, pgfplots
"thought" the first non-header row has only the cell 0,0.66582
rather than two cells 0
and 0.66582
, and so on, which explains the error messages. And yes, I can see how this might be confusing, after all you specify only in the plot which column goes where.
Nice answer, could you briefly explain why we must do that change?
– Raaja
2 days ago
1
@Raaja I added some mini-explanation.
– marmot
2 days ago
1
Thanks for the little brief, its clear for me now!
– Raaja
2 days ago
add a comment |
up vote
5
down vote
accepted
After moving col sep=comma
to the right place, the errors are gone.
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
pgfplotsset{width=7cm,compat=1.8}
usepackage{pgfplotstable}
begin{document}
begin{tikzpicture}
pgfplotstableread[col sep = comma]{
T3,v11
0,0.66582
0.000125,0.66582
0.00025,0.66582
0.000375,0.66582
0.0005,0.66582
0.000625,0.66582
0.00075,0.66582
0.000875,0.66582
0.001,0.66582
0.001125,0.66582
}dummydata
begin{axis}[
domain=-4:4,
samples y=0, ytick={1,...,4},
]
{
addplot3 table [x =T3, y expr=1, z=v11]
{dummydata};
}
end{axis}
end{tikzpicture}
end{document}
MINI-EXPLANATION: When you load the data, you need to tell pgfplots
what the structure of the file is, i.e. how it is supposed to decompose it into rows and columns, i.e. cells. If you do not tell pgfplots
that the columns are separated by commas, say, it will assume they are separated by spaces or tabs, which is why your second example worked. In your first example, pgfplots
"thought" the first non-header row has only the cell 0,0.66582
rather than two cells 0
and 0.66582
, and so on, which explains the error messages. And yes, I can see how this might be confusing, after all you specify only in the plot which column goes where.
Nice answer, could you briefly explain why we must do that change?
– Raaja
2 days ago
1
@Raaja I added some mini-explanation.
– marmot
2 days ago
1
Thanks for the little brief, its clear for me now!
– Raaja
2 days ago
add a comment |
up vote
5
down vote
accepted
up vote
5
down vote
accepted
After moving col sep=comma
to the right place, the errors are gone.
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
pgfplotsset{width=7cm,compat=1.8}
usepackage{pgfplotstable}
begin{document}
begin{tikzpicture}
pgfplotstableread[col sep = comma]{
T3,v11
0,0.66582
0.000125,0.66582
0.00025,0.66582
0.000375,0.66582
0.0005,0.66582
0.000625,0.66582
0.00075,0.66582
0.000875,0.66582
0.001,0.66582
0.001125,0.66582
}dummydata
begin{axis}[
domain=-4:4,
samples y=0, ytick={1,...,4},
]
{
addplot3 table [x =T3, y expr=1, z=v11]
{dummydata};
}
end{axis}
end{tikzpicture}
end{document}
MINI-EXPLANATION: When you load the data, you need to tell pgfplots
what the structure of the file is, i.e. how it is supposed to decompose it into rows and columns, i.e. cells. If you do not tell pgfplots
that the columns are separated by commas, say, it will assume they are separated by spaces or tabs, which is why your second example worked. In your first example, pgfplots
"thought" the first non-header row has only the cell 0,0.66582
rather than two cells 0
and 0.66582
, and so on, which explains the error messages. And yes, I can see how this might be confusing, after all you specify only in the plot which column goes where.
After moving col sep=comma
to the right place, the errors are gone.
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
pgfplotsset{width=7cm,compat=1.8}
usepackage{pgfplotstable}
begin{document}
begin{tikzpicture}
pgfplotstableread[col sep = comma]{
T3,v11
0,0.66582
0.000125,0.66582
0.00025,0.66582
0.000375,0.66582
0.0005,0.66582
0.000625,0.66582
0.00075,0.66582
0.000875,0.66582
0.001,0.66582
0.001125,0.66582
}dummydata
begin{axis}[
domain=-4:4,
samples y=0, ytick={1,...,4},
]
{
addplot3 table [x =T3, y expr=1, z=v11]
{dummydata};
}
end{axis}
end{tikzpicture}
end{document}
MINI-EXPLANATION: When you load the data, you need to tell pgfplots
what the structure of the file is, i.e. how it is supposed to decompose it into rows and columns, i.e. cells. If you do not tell pgfplots
that the columns are separated by commas, say, it will assume they are separated by spaces or tabs, which is why your second example worked. In your first example, pgfplots
"thought" the first non-header row has only the cell 0,0.66582
rather than two cells 0
and 0.66582
, and so on, which explains the error messages. And yes, I can see how this might be confusing, after all you specify only in the plot which column goes where.
edited 2 days ago
answered 2 days ago
marmot
78.7k487166
78.7k487166
Nice answer, could you briefly explain why we must do that change?
– Raaja
2 days ago
1
@Raaja I added some mini-explanation.
– marmot
2 days ago
1
Thanks for the little brief, its clear for me now!
– Raaja
2 days ago
add a comment |
Nice answer, could you briefly explain why we must do that change?
– Raaja
2 days ago
1
@Raaja I added some mini-explanation.
– marmot
2 days ago
1
Thanks for the little brief, its clear for me now!
– Raaja
2 days ago
Nice answer, could you briefly explain why we must do that change?
– Raaja
2 days ago
Nice answer, could you briefly explain why we must do that change?
– Raaja
2 days ago
1
1
@Raaja I added some mini-explanation.
– marmot
2 days ago
@Raaja I added some mini-explanation.
– marmot
2 days ago
1
1
Thanks for the little brief, its clear for me now!
– Raaja
2 days ago
Thanks for the little brief, its clear for me now!
– Raaja
2 days ago
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461669%2fplotting-a-3d-data-set-from-a-csv-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown