0

Answering y-axis units tikz, I firstly come upon this solution:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}\pgfplotsset{compat=1.13}
\usepackage{siunitx}
\begin{document}
\begin{tikzpicture}[
    ]
    \begin{axis}[%
    xmin=1,
    xmax=5,
    xtick={\empty},
    ymin=4,
    ymax=6,
    axis background/.style={fill=white},
    %yticklabel={$\pgfmathprintnumber{\tick}$~V}      %% this works
    yticklabel={\SI{\pgfmathprintnumber{\tick}}{V}}   %% this hangs 
    ]
    \addplot [color=blue, forget plot]
    table[row sep=crcr]{%
        1   4.1\\
        2   4.9\\
        3   5\\
        5   5.6\\
    };
\end{axis}     
\end{tikzpicture}
\end{document}

That mean, I used \SI{}{} in the yticklabel key. Unfortunately, this seems to create an infinite loop: the compilations hangs in:

[...]
 (/usr/share/texlive/texmf-dist/tex/latex/beamer/translator/dicts/translator-bas
ic-dictionary/translator-basic-dictionary-English.dict)
(/usr/share/texlive/texmf-dist/tex/latex/siunitx/siunitx-abbreviations.cfg)

...and the only way out is interrupting it.

Is it possible to fix this or it's just an operator (me) error?

2
  • 2
    Use \tick directly and use the siunitx tools to round the number, e.g. \SI[round-mode = places,round-precision = 1]{\tick}{V} – Ulrike Fischer May 15 '17 at 17:07
  • @UlrikeFischer thanks --- it works. Going to update the other answer. If you write this as an answer I'll be happy to accept it. – Rmano May 15 '17 at 17:10
3

Use \tick directly and use the siunitx tools to round the number, e.g. \SI[round-mode = places,round-precision = 1]{\tick}{V}

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}\pgfplotsset{compat=1.13}
\usepackage{siunitx}
\begin{document}
\begin{tikzpicture}[
    ]
    \begin{axis}[%
    xmin=1,
    xmax=5,
    xtick={\empty},
    ymin=4,
    ymax=6,
    axis background/.style={fill=white},
    yticklabel={\SI[round-mode = places,round-precision = 1]{\tick}{V}}   
    ]
    \addplot [color=blue, forget plot]
    table[row sep=crcr]{%
        1   4.1\\
        2   4.9\\
        3   5\\
        5   5.6\\
    };
\end{axis}     
\end{tikzpicture}
\end{document}

enter image description here

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.