14

the y-axis of my diagram uses small numbers like 0,005. I don't want to use a multiplier like 10^-3 which appears by default. If I remove it with

scaled x ticks = false, x tick label style={/pgf/number format/fixed},

the tick labels are not accurate enough and show ony 0 or 0,1:

enter image description here

Code used:

\begin{tikzpicture}
\begin{axis}[%
scaled x ticks = false,
x tick label style={/pgf/number format/fixed},
scaled y ticks = false,
scale only axis,
width=6cm,
height=5cm,
xmin=0, xmax=30000,
ymin=-0.001, ymax=0.006,
ymajorgrids,
axis on top]

How can i get this right?

  • By indenting code with four spaces you get a code block, as I did in my edit. When pasting in code, you can select the entire block and hit Ctrl + K (or click the {} button above the text field) to get everything indented. Also, it's always best to provide a complete, compilable, yet minimal example, a minimal working example (MWE). – Torbjørn T. Nov 23 '11 at 15:23
23

Try adding

yticklabel style={/pgf/number format/fixed,
                  /pgf/number format/precision=3}

as an option to the axis.

enter image description here

Left, with /pgf/number format/precision=3, right without. Complete code:

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
   scaled x ticks = false,
   x tick label style={/pgf/number format/fixed},
   scaled y ticks = false,
   yticklabel style={/pgf/number format/fixed,
                     /pgf/number format/precision=3},
   scale only axis,
   width=6cm,
   height=5cm,
   ymajorgrids,
   axis on top]
      \addplot coordinates {(0,0) (0.2,0.01)};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[%
   scaled x ticks = false,
   x tick label style={/pgf/number format/fixed},
   scaled y ticks = false,
   yticklabel style={/pgf/number format/fixed},
   scale only axis,
   width=6cm,
   height=5cm,
   ymajorgrids,
   axis on top]
     \addplot coordinates {(0,0) (0.2,0.01)};
\end{axis}
\end{tikzpicture}
\end{document}

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.