2021-10-29

Filtering/Indexing a semicolon sepeated csv file with floating point numbers

I want to filter and plot my data by two criteria. First I want to filter the data by column Test and then by Test No. and then plot it. Unfortunately, I am getting nowhere with the filtering. I tried it directly with the package pgfplots. After that I tried the package pgfplotstable, but here I failed as well.

The following posts did not help me:

My result:

\documentclass[a4paper,12pt,headsepline]{scrartcl}
\usepackage{tikz,pgfplots,siunitx,pgfplotstable}
\usepgfplotslibrary{units}
\pgfplotsset{compat=1.18}
\usepackage{filecontents}
%\begin{filecontents}{data.csv}
%Test No.;Test;time [s];u [ms]
%A1;A;3;0.045
%A2;A;5;0.06
%A2;A;4;0.05
%A2;A;3;0.04
%A2;A;2;0.03
%A2;A;1;0.02
%A2;A;0;0.01
%A3;A;3;0.044
%B1;B;10;0.045
%B1;B;20;0.06
%B1;B;30;0.05
%B1;B;40;0.04
%B1;B;50;0.03
%B1b;B;10;0.02
%B1b;B;20;0.01
%B1b;B;30;0.044
%B1b;B;40;0.045
%B1b;B;50;0.06
%C1;C;10;0.05
%C1;C;20;0.04
%C1;C;30;0.03
%C1;C;40;0.02
%C1;C;50;0.01
%C1;C;60;0.044
%C1;C;70;0.8
%C2;C;60;0.4
%\end{filecontents}


\begin{document}


\begin{tikzpicture}
    \begin{axis}
    [
        width=\linewidth,
        grid=major,
        grid style={dashed,gray!30},
        xlabel=$time$,
        ylabel=$u$,
        x unit=\si{\second},
        y unit=\si{\meter\per\second}
    ]
    \addplot table [x={time [s]}, y={u [ms]}, col sep=semicolon] {data.csv};
    \end{axis}
\end{tikzpicture}
\end{document}

Data in one plot



from Recent Questions - Stack Overflow https://ift.tt/3pNPEqn
https://ift.tt/3vUNAhl

No comments:

Post a Comment