pgfplots raw gnuplot 由于 babel ngerman 无法正常工作

pgfplots raw gnuplot 由于 babel ngerman 无法正常工作

考虑以下 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}

使用二维样本数据(取自另一篇 SO 文章)

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

为什么加载时没有显示任何图表babel?预期结果:

在此处输入图片描述

答案1

问题在于babel改变了双引号的含义"

添加\shorthandoff{"}before\addplot即可解决问题。请注意,变音符号 shothand 处理将被禁用,直到下一个\end{...}

答案2

如果我添加,就没有问题了\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}

在此处输入图片描述

相关内容