Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Hi the decimal separator of the xticks is a point i would the comma how can i do?

\documentclass[border=0.5mm,12pt]{standalone}

\usepackage{siunitx}                       % SI Package

\sisetup{%
         output-decimal-marker={,},
         table-format = 3.1%
        }

\usepackage{pgfplots}        % Grafici

\pgfplotsset{%
            mesh line legend/.style={legend image code/.code=\meshlinelegend#1},%
            /pgf/number format/use comma,%
            compat=newest,%
%            height=9cm,%
            width=12cm%
}


\begin{document}
%\begin{figure}
\begin{tikzpicture}
\pgfdeclarehorizontalshading{stefan}{50bp}{
color(0.00000000000000bp)=(violet);
color(8.33333333333333bp)=(blue);
color(16.66666666666670bp)=(cyan);
color(25.00000000000000bp)=(green);
color(33.33333333333330bp)=(yellow);
color(41.66666666666670bp)=(orange);
color(50.00000000000000bp)=(red)
}
\begin{axis}[%
grid=major,
legend pos=north west,
legend cell align=left,
no markers,
xmin=-0.3,
xmax=0.3,
ymin=0,
ymax=6,
yticklabel shift=2pt,
xticklabel shift=2pt,
point meta min={-0.3},
point meta max={0.3},
tick style={thin,black},
xticklabel style={text height=1.5ex},
xticklabels={%
        $-0.4$,
        $-0.3$,
        $-0.2$,
        $-0.1$,
        $\mu$,
        $0.1$,
        $0.2$,
        $0.3$,
        $0.4$
    },
extra x ticks={-0.4,-0.3,...,0.4},
extra x tick labels={%
        $-0.4$,
        $-0.3$,
        $-0.2$,
        $-0.1$,
        $\mu$,
        $0.1$,
        $0.2$,
        $0.3$,
        $0.4$
    },
extra x tick style={
    xticklabel pos=right,
    xticklabel style={text depth=0pt}
},
extra y ticks={0,1,...,6},
extra y tick style={
    yticklabel pos=right
},
minor tick num=4,
xlabel=\large $x$,
ylabel=\large $f_{\mu,\sigma^2}(x)$,
colorbar horizontal,
colorbar style={
    xticklabels={%
        $-0.4$,
        $-0.3$,
        $-0.2$,
        $-0.1$,
        $\mu$,
        $0.1$,
        $0.2$,
        $0.3$,
        $0.4$
    },
    xticklabel shift=2pt,
    xticklabel style={text height=1.5ex}
},
axis line style={draw=none}, after end axis/.append code={\draw (rel axis cs:0,0) rectangle (rel axis cs:1,1);},
colormap={new}{color(0cm)=(violet);color(1cm)=(blue);color(2cm)=(cyan);color(3cm)=(green);color(4cm)=(yellow);color(5cm)=(orange);color(6cm)=(red)},
after end axis/.append code={%
    \draw ({rel axis cs:0,0}-|{axis cs:0,0}) -- ({rel axis cs:0,1}-|{axis cs:0,0});
}
]
\addplot gnuplot[
    shading=stefan,
    draw=none,
    shader=interp,
    id=DoG,
    samples=1000,
    domain=-0.3:0.3,
    y domain=0:1
]{((1/(sqrt(2*pi*0.08**2)))*exp(-(x-0)**2/(2*0.08**2)))}\closedcycle;
\addlegendimage{empty legend}\addlegendentry{$\mu=27,6\si{\second}$}
\addlegendimage{empty legend}\addlegendentry{$\sigma^2=0,01\si{\second}$}
\end{axis}
\end{tikzpicture}
\end{document}
share|improve this question
2  
Just input them as $-0{,}4$ or \num{-0.4}. Please, try and make shorter examples. –  egreg Jun 21 '12 at 12:43

2 Answers 2

up vote 7 down vote accepted

Instead of providing the numbers and the \mu as an explicit list, you could use the xticklabel key to check whether the current tick is at 0, and replace it with \mu. If it isn't, you can print the number using \pgfmathprintnumber{\tick}, which can be formatted using the /pgf/number format options. You should use \pgfmathapproxequalto{\tick}{0} to account for numeric errors introduced when using the {-0.3,-0.2,...,0.3} notation.

So if you set

xticklabel={
    \pgfmathapproxequalto{\tick}{0}%
    \ifdim\pgfmathresult pt=1pt
        $\mu$
    \else
        \pgfmathprintnumber[fixed]{\tick}
    \fi
},
extra x ticks={-0.4,-0.3,...,0.4},
extra x tick label={
    \pgfmathapproxequalto{\tick}{0}%
    \ifdim\pgfmathresult pt=1pt
        $\mu$
    \else
        \pgfmathprintnumber[fixed]{\tick}
    \fi
}

your output will be

share|improve this answer

You are telling LaTeX to print $-0.4$ and so on. Just write

$-0{,}4$

or, since you're using siunitx and the output-decimal-marker={,} option, just use

\num{-0.4}

The tick labels are just typeset in a box, as far as I can tell.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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