latex - TikZ: plotting data file with missing values -
i have data:
data2 missing third point. thought, i'd define 2 different x columns , assign data2 x2.
problem: third point of data1 goes 3 in compiled graphic. if have different , more values, points start go anywhere, not belong.
that code i've used:
\addplot[only marks, mark = diamond, color = orange, mark size = 3pt] table[x=x1, y=data1]{example.dat}; \addlegendentry{data1}; \addplot[only marks, mark = square, color = gray, mark size = 3pt] table[x=x2, y=data2]{example.dat}; \addlegendentry{data2}; \addplot[only marks, mark = o, color = blue, mark size = 3pt] table[x=x1, y=data3]{example.dat}; \addlegendentry{data3}; and graph get:
thanks lot!
btw. in real data 1 data set missing x/y value in middle of data. hope doesn't matter compared example.
pgfplots interpreting 2 tabs single separator. thus, sees data file as:
x1 x2 data1 data2 data3 0 0 1 2 3 1 1 1 2 3 2 1 3 solution 1. can replace empty cells nan. pgfplots interpret correctly:
x1 x2 data1 data2 data3 0 0 1 2 3 1 1 1 2 3 2 nan 1 nan 3 solution 2. use type of separator (e.g., semicolons or commas):
\begin{filecontents*}{example.csv} x1;x2;data1;data2;data3 0;0;1;2;3 1;1;1;2;3 2;;1;;3 \end{filecontents*} \pgfplotstableread[col sep = semicolon]{example.csv}\mydata \begin{document} ... here i've included data file in tex file, should work separate data file.
wiki



Comments
Post a Comment