TeX - LaTeX Asked on December 13, 2021
I’m trying to place nodes inside a TikZ axis using csvreader
command from simplecsv
package. However, somehow, the following does not work:
documentclass{article}
usepackage[utf8]{inputenc}
usepackage{csvsimple}
usepackage{pgfplots}
usepackage{tikz}
title{Test}
begin{document}
begin{filecontents*}{xx.csv}
xv,yv,z
1.0,2.2,3.0
2.0,3.2,1.0
end{filecontents*}
maketitle
begin{tikzpicture}
begin{axis}[
xmin=0,
ymin=0,
xmax=4,
ymax=4,
]
node at (axis cs:2, 2) {x};
csvreader[head to column names]{xx.csv}{}{
node at (axis cs:xv, yv) {y};
}
end{axis}
end{tikzpicture}
end{document}
I always get a Argument of pgfmathfloatparse@@ has an extra }.
. Does anybody spot what is going wrong here? I’ve been trying this for a while now..
I’ve put this snippet on Overleaf. Please feel free to investigate it there: https://www.overleaf.com/read/gdczbgvqmrzt
This doesn't really answer the question as stated, but it shows how to get nodes near coords
with SI
. From your comment to Nico's answer this seems to be what you're after in the end. I'll just delete this if it isn't what you need, or if you feel it's not the right place for it.
documentclass{article}
usepackage{pgfplots}
usepackage{siunitx}
begin{document}
begin{filecontents*}{xx.csv}
xv,yv,z
1.0,2.2,3.0
2.0,3.2,1.0
end{filecontents*}
begin{tikzpicture}
begin{axis}[
xmin=0,
ymin=0,
xmax=4,
ymax=4,
]
addplot [
mark=none,
draw=none,
nodes near coords={SI{pgfplotspointmeta}{m}}
]
table[
x=xv,
y=yv,
meta=z,
col sep=comma,
point meta=explicit symbolic
] {xx.csv};
end{axis}
end{tikzpicture}
end{document}
Answered by Torbjørn T. on December 13, 2021
documentclass[tikz]{standalone}
usepackage{pgfplots, csvsimple, siunitx}
pgfplotsset{compat=newest}
begin{document}
begin{filecontents*}{xx.csv}
xv,yv,z
1.0,2.2,3.0
2.0,3.2,1.0
end{filecontents*}
begin{tikzpicture}
csvreader[head to column names]{xx.csv}{xv=x,yv=y,z=val}{
begin{axis}[
xmin=0,
ymin=0,
xmax=4,
ymax=4
]
node at (axis cs:2, 2) {x};
node[draw] at (axis cs:x,y){SI{val}{metrepersecond}};
end{axis}
}
end{tikzpicture}
end{document}
Answered by Nico on December 13, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP