4

I'm trying to create a diagram with three x-axes at the bottom. I found a code which creates 3 axes but when I try to plot the data from a csv file I get an error stating:

! Package pgfkeys Error: I do not know the key '/tikz/col sep', to which you passed 'comma', and I am going to ignore it. Perhaps you misspelled it.

I have no problem plotting csv files in other settings but somehow I can't get this to work. What am I doing wrong? Here is the file: test.csv

Here is my code:

\begin{document}
\usepackage{pgfplots}

    \begin{tikzpicture}
        \pgfplotsset{    
        every axis x label/.style={
        at={(ticklabel* cs:1.05)},
        yshift = -7.5pt,
        anchor=west,},
        width=14cm,
        height=7cm,
        every axis y label/.style={at={(current axis.above origin)},
        anchor=north east,
        yshift = 1cm,} }
        \begin{axis}[
        scaled y ticks = false,
          y tick label style={/pgf/number format/fixed,
          /pgf/number format/1000 sep = \thinspace},
          xmin=0,xmax=3,
          xlabel={$Re$},
          ylabel={$\delta ~\text{[mm]}$},
          ymin=0, ymax=2,
          ymajorgrids=true, xmajorgrids=true,
          axis y line*=left, axis x line*=bottom]
          \addplot[color=red,smooth,thick, col sep=comma] {test.csv};
        \end{axis}
        \begin{axis}[
            xmin=0,xmax=70,%--- CF,
            hide y axis,
             axis x line*=none,
            ymin=0, ymax=2,
            xlabel={$\dot{V} ~[\text{L} / \text{h}]$},
            x label style={yshift=-0.8cm},
            x tick label style={yshift=-0.8cm}
            ]
        \addplot[color=blue,smooth,thick] coordinates { 
                  (2.28,1.09068)
            (1.67,0.97372)
            (1.11,0.832298376)
            (0.55,0.634618222)
            (0.27,0.46422) };
        \end{axis} 
          \begin{axis}[
            xmin=0,xmax=35,
            hide y axis,
            axis x line*=none,
            ymin=0, ymax=2,
            xlabel={$\dot{V}/A ~[\text{m}^3 / \text{h} \text{m}^2]$},
            x label style={yshift=-1.6cm},
            x tick label style={yshift=-1.6cm}
            ]
        \addplot[color=black,thick] coordinates { 
                  (2.28,1.09068)
            (1.67,0.97372)
            (1.11,0.832298376)
            (0.55,0.634618222)
            (0.27,0.46422) };
        \end{axis}   
    \end{tikzpicture}
\end{document}
4
  • Please add a fully compilable MWE. Commented Dec 31, 2018 at 14:42
  • What do you mean? An example where the code works?
    – BubbleFlow
    Commented Dec 31, 2018 at 15:10
  • Welcome to TeX.SE! Try \addplot[color=red,smooth,thick] table[col sep=comma] {test.csv};.And yes, the code is supposed to be compilable in principle, meaning you should add \documentclass..., move \begin{document} down and provide us with a small version of test.csv, too.
    – user121799
    Commented Dec 31, 2018 at 15:15
  • Okay but the code already begins with \beging{document}. I had uploaded the sample file but I can just write out the data if it is needed. I tried that before but it doesn't work either.
    – BubbleFlow
    Commented Dec 31, 2018 at 15:22

1 Answer 1

3

This contains an answer to your question, I think, and an MWE. The answer to your question is that you should try

\addplot[color=red,smooth,thick] table[col sep=comma,header=false,x index=0,y index=1] {test.csv};

which works if your test.csv data has a format in which there is a comma separator. This is because col sep=comma is a valid option for a table, but not for a plot. Notice that I also increased xmax for that plot since with your setting the full plot gets clipped away.

To make it an MWE, I

  1. added a document class,
  2. loaded amsmath (since you are using \text),
  3. moved \usepacage{pgfplots} above \begin{document},
  4. added test.csv to the MWE via filecontents to make it easier to test.

I did not change any of the details, also because I do not really now what Re stands for. If it stands for real part, I wouldn't set it in math mode.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{filecontents}
\begin{filecontents*}{test.csv}
70.4,1.012015504
52.8,0.919477106
35.2,0.803237238
17.6,0.637529818
8.8,0.506007752
\end{filecontents*}
\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
    \pgfplotsset{    
    every axis x label/.style={
    at={(ticklabel* cs:1.05)},
    yshift = -7.5pt,
    anchor=west,},
    width=14cm,
    height=7cm,
    every axis y label/.style={at={(current axis.above origin)},
    anchor=north east,
    yshift = 1cm,} }
    \begin{axis}[
    scaled y ticks = false,
      y tick label style={/pgf/number format/fixed,
      /pgf/number format/1000 sep = \thinspace},
      xmin=0,xmax=75,
      xlabel={$Re$},
      ylabel={$\delta ~\text{[mm]}$},
      ymin=0, ymax=2,
      ymajorgrids=true, xmajorgrids=true,
      axis y line*=left, axis x line*=bottom]
      \addplot[color=red,smooth,thick] table[col sep=comma,header=false,
      x index=0,y index=1] {test.csv};
    \end{axis}
    \begin{axis}[
        xmin=0,xmax=70,%--- CF,
        hide y axis,
         axis x line*=none,
        ymin=0, ymax=2,
        xlabel={$\dot{V} ~[\text{L} / \text{h}]$},
        x label style={yshift=-0.8cm},
        x tick label style={yshift=-0.8cm}
        ]
    \addplot[color=blue,smooth,thick] coordinates { 
              (2.28,1.09068)
        (1.67,0.97372)
        (1.11,0.832298376)
        (0.55,0.634618222)
        (0.27,0.46422) };
    \end{axis} 
      \begin{axis}[
        xmin=0,xmax=35,
        hide y axis,
        axis x line*=none,
        ymin=0, ymax=2,
        xlabel={$\dot{V}/A ~[\text{m}^3 / \text{h} \text{m}^2]$},
        x label style={yshift=-1.6cm},
        x tick label style={yshift=-1.6cm}
        ]
    \addplot[color=black,thick] coordinates { 
              (2.28,1.09068)
        (1.67,0.97372)
        (1.11,0.832298376)
        (0.55,0.634618222)
        (0.27,0.46422) };
    \end{axis}   
\end{tikzpicture}
\end{document}

enter image description here

1
  • Thank you. That did the trick. I only added the part with table [col sep=comma,header=false, x index=0,y index=1] . BTW, "Re" stands for the Reynolds-number of a fluid flow. My intention was to make the fonts appear identical. Your answer really helped me, as I was stuck on this for over 2 days now :D!!
    – BubbleFlow
    Commented Dec 31, 2018 at 19:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .