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.

How do I disable exponent notation on logarithmic scale?

I want ...,$10^0$,$10^1$,$10^2$,... replaced by ...,1,10,100,...

I have tried to play with this default(pgfplots manual p. 209):

\pgfplotsset{ log base 10 number format code/.code={$10^{\pgfmathprintnumber{#1}}$}
}

But I can't make it work, and it seems to be a complicated way to do a simple thing.


\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
  \pgfplotsset{log base 10 number format code/.code={$fun^{\pgfmathprintnumber{#1}}$}}  
  \begin{semilogxaxis}
    [xmin=1, xmax=1000, domain=1:1000]
    \addplot {ln(x)};
  \end{semilogxaxis}
\end{tikzpicture}
\end{document}

Just for fun

share|improve this question
2  
I will add this to the pgfplots todo list (the requests came up a couple of times now). It seems an easily usable predefined switch is adequate here. –  Christian Feuersänger Dec 10 '11 at 21:04
add comment

1 Answer 1

up vote 10 down vote accepted

Do you mean something like this:

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
  \pgfplotsset{%
    x tick label style={/pgf/number format/1000 sep=\,},
    log base 10 number format code/.code={%
        $\pgfmathparse{10^(#1)}\pgfmathprintnumber{\pgfmathresult}$%
    }%
  }  
  \begin{semilogxaxis}
    [xmin=1, xmax=1000, domain=1:1000]
    \addplot {ln(x)};
  \end{semilogxaxis}
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
Yes thank you. Still a bit complicated, but I guess, I have to live with the fact, that there is no boolean to accomplice the task. –  Hans-Peter E. Kristiansen Dec 10 '11 at 10:55
    
I sounds like you don't understand the code. Maybe I misunderstand your- –  Marco Daniel Dec 10 '11 at 13:50
    
Your answer works hurray. I will accept your answer -> Though still hoping for a simpler solution, not involving extracting an exponent converting it into a number, and adding it back into the style. –  Hans-Peter E. Kristiansen Dec 10 '11 at 13:55
    
Thanks for the code provided, worked most of the times for my purposes! However, I noticed, that your code does not correctly handle negative exponents, i.e. 10^(-0.3) leads to a label of "2" (==10^0.3) instead of "0.5". I worked around by changing your code to \pgfmathparse{1/10^(#1)} however, is there a general to avoid a wrong handling of the sign of #1 ? –  user32597 Jun 21 '13 at 9:47
add comment

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.