8

Consider the following MWE

% !TeX program = lualatex
\RequirePackage{luatex85}
\documentclass[border=1pt]{standalone}

\usepackage{pgfplots}
    \pgfplotsset{compat=newest}

\usepackage[main=ngerman,english]{babel}

\begin{document}

\centering
\begin{tikzpicture}
    \begin{axis}[
        width=10cm, height=7cm,
        tick label style={font=\large},
        xmin=4675.5, xmax=4676.5,
        xtick={4675.5,4675.8,...,4676.5},
        axis x line=box,
        axis y line=box,
        xlabel=$x$-values,
        ylabel=$y$-values,
        xlabel shift=0pt,
        ylabel shift=0pt
    ]
    \addplot gnuplot [raw gnuplot, id=test, mark=none]{
    set xrange [4675.5:4676.5];
    set yrange [0.05:0.065];
    plot "samples.dat" using ($1):($2) with lines;
    };

    \end{axis}
\end{tikzpicture}

\end{document}

With 2-dimensional sample data (taken from another SO post)

4675.47  0.06453669
4675.5  0.06474017
4675.53  0.06501856
4675.56  0.06455813
4675.59  0.06477106
4675.62  0.06479543
4675.65  0.06419399
4675.68  0.06485552
4675.71  0.0648725
4675.74  0.06467944
4675.77  0.06463394
4675.8  0.06475285
4675.83  0.06499603
4675.86  0.06492839
4675.89  0.06493193
4675.92  0.06504349
4675.95  0.06517189
4675.98  0.0652523
4676.01  0.06532519
4676.04  0.06520497
4676.07  0.06475184
4676.1  0.06509843
4676.13  0.06487284
4676.16  0.06456631
4676.19  0.06495201
4676.22  0.06473787
4676.25  0.06436973
4676.28  0.06461342
4676.31  0.06483281
4676.34  0.06478729
4676.37  0.06505747
4676.4  0.06462811

Why do I get no plot when loading babel? Expected result:

enter image description here

9

The problem is that babel changes the meaning of double quotes ".

Adding \shorthandoff{"} before \addplot will solve the problem. Note that umlaut shothand processing will be disabled until the next following \end{...}.

  • Thank you! I will then switch to using ' instead of " in the gnuplot code in the future. – Christoph90 Jan 20 '18 at 12:43
8

I have no problem if I add \usetikzlibrary{babel}.

\RequirePackage{luatex85}
\documentclass[border=4]{standalone}
\usepackage[main=ngerman,english]{babel}

\usepackage{pgfplots}
\usetikzlibrary{babel}

\pgfplotsset{compat=newest}

\begin{document}

\centering
\begin{tikzpicture}
    \begin{axis}[
        width=10cm, height=7cm,
        tick label style={font=\large},
        xmin=4675.5, xmax=4676.5,
        xtick={4675.5,4675.8,...,4676.5},
        axis x line=box,
        axis y line=box,
        xlabel=$x$-values,
        ylabel=$y$-values,
        xlabel shift=0pt,
        ylabel shift=0pt
    ]
    \addplot gnuplot [raw gnuplot, id=test, mark=none]{
    set xrange [4675.5:4676.5];
    set yrange [0.05:0.065];
    plot "samples.dat" using ($1):($2) with lines;
    };

    \end{axis}
\end{tikzpicture}

\end{document}

enter image description here

  • This is nice, thanks. I will load that library by default from now on. – Christoph90 Jan 20 '18 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.