4

I am trying to plot an individual colorbar (with no axis), using the code below (MWE):

\documentclass{standalone}
\usepackage{pgfplots}
    \pgfplotsset{compat=1.3}

\begin{document}
    \begin{tikzpicture}
        \begin{axis}[
            hide axis,
            scale only axis,
            colorbar,
            point meta min=0,
            point meta max=1,
            colorbar style={height=5cm}]
            \addplot [draw=none] coordinates {(0,0)};
        \end{axis}
    \end{tikzpicture}
\end{document}

It works perfectly, but if I add the following options into my preamble:

\pgfplotsset{every linear axis/.append style={
    /pgf/number format/.cd,
    use comma,
    1000 sep={\,},
}}

the compiling fails, giving that error message:

! Package pgfkeys Error: I do not know the key '/pgf/number
format/xshift', to  which you passed '0.3cm', and I am going to ignore
it. Perhaps you misspelled it.

Since I do need those options for other plots, how can I get rid of this error? And how can I define the formatting options for the colorbar ticks?

Thanks.

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
Dorian
  • 628

1 Answers1

2

The easiest and probably the most reliable solution is spelling out the path explicitly without changing the key family.

\documentclass{standalone}
\usepackage{pgfplots}
    \pgfplotsset{compat=1.12}

\pgfplotsset{every linear axis/.append style={
    /pgf/number format/use comma,
    /pgf/number format/1000 sep={\,},
  }
}

\begin{document}
    \begin{tikzpicture}
        \begin{axis}[
            hide axis,
            scale only axis,
            colorbar,
            point meta min=0,
            point meta max=1,
            colorbar style={height=5cm}]
            %\addplot [draw=none] coordinates {(0,0)};
        \end{axis}
    \end{tikzpicture}
\end{document}

Otherwise you have a few options, such setting the keys in a /.code handler or any of the solutions linked in Jake's comment etc.

percusse
  • 157,807