0

Is it possible to use Format/Fixed and comma as separator in a tikz picture?

Please find below an example picture: enter image description here

I used the code below and got the following error message: Package pgfkeys Error: I do not know the key '/pgf/number format/smooth' and I am going to ignore it.

\documentclass[a4paper, 12pt]{book}
\usepackage{fontspec}
\setmainfont{Cambria}
\setsansfont{Calibri}
\newfontfamily\Headerfamily{Calibri}

\usepackage[ngerman]{babel}
\usepackage{graphicx}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepackage{mathtools}
\usepackage{siunitx}

\newcommand\arr{\tikz[baseline=-0.6ex]\draw[-latex] (0,0) -- + (7mm,0);}

\begin{document}
    \begin{tikzpicture}
        \begin{axis}[domain=0:45,
            /pgf/number format=use comma,
            /pgf/number format/fixed,
                samples=180,
                grid=major,smooth,
                xmin=0,
                xmax=45,
                ymin=-0.1,
                ymax=0.1,
                xlabel={\si{\celsius} \arr},
                ylabel={\si{\radian} \arr},
                legend pos=north west]

            \legend{\emph{Drift}}
        \addplot [color=black,thick]
            {(0.000001*x^3+
            (-0.000035*x^2+
            (-0.000315*x};
        \end{axis}
    \end{tikzpicture}
\end{document}
1
  • Sure. Change the number format with /pgf/number format=use comma,/pgf/number format/fixed. Oct 6, 2018 at 17:15

1 Answer 1

1

You just need to add one line. See comment in the code.

% used PGFPlots v1.16
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \pgfplotsset{
        compat=1.3,
    }
\usepackage{siunitx}
    \newcommand\arr{\tikz[baseline=-0.6ex]\draw[-latex] (0,0) -- + (7mm,0);}
\begin{document}
    \begin{tikzpicture}
        \begin{axis}[
            /pgf/number format/.cd,
                fixed,
                use comma,
            /tikz/.cd,      % <--added
            domain=0:45,
            samples=180,
            grid=major,
            smooth,
            xmin=0,
            xmax=45,
            ymin=-0.1,
            ymax=0.1,
            xlabel={\si{\celsius} \arr},
            ylabel={\si{\radian} \arr},
            legend pos=north west,
        ]

            \addplot [color=black,thick]
                {0.000001*x^3+
                -0.000035*x^2+
                -0.000315*x};

            \legend{\emph{Drift}}
        \end{axis}
    \end{tikzpicture}
\end{document}

image showing the result of above code

You must log in to answer this question.

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