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
3  
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
    
@ChristianFeuersänger: Is log ticks with fixed point the easily usable switch you commented about? –  Ben Voigt Oct 24 at 22:08
    
@Ben Voigt: I believe that you are correct. Maybe log ticks with fixed point has been added to TikZ after my question!? Will you post an answer? –  Hans-Peter E. Kristiansen Oct 25 at 8:06
    
@BenVoigt Yes, it is. I suppose your request is motivated by tex.stackexchange.com/questions/208891/…, right? Let us continue any comments/problem analysis on that link. –  Christian Feuersänger Oct 25 at 9:33
    
@Christian Feuersänger: Are you the helpful person, who added this feature? -If so, will you post a more contemporary answer to this question. /OP –  Hans-Peter E. Kristiansen Oct 25 at 15:25

2 Answers 2

up vote 3 down vote accepted

In addition to the other answer, more recent versions of pgfplots come with the style log ticks with fixed point. It does almost the same: it reconfigures the number printer such that ticks are displayed in fixed point format. Its logic is somewhat more complicated to avoid rounding inaccuracies and different log bases.

Here is the result with this new feature:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\begin{document}
\begin{tikzpicture}
  \begin{semilogxaxis}[
    xmin=1,
    xmax=1000,
    domain=1:1000, 
    log ticks with fixed point,
    x tick label style={/pgf/number format/1000 sep=\,},
    ]
    \addplot {ln(x)};
  \end{semilogxaxis}
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer

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
    
Agreed, this answer does not work. I found a better but messy solution xticklabel={\pgfmathfloatparsenumber{\tick}\pgfmathfloatexp{\pgfmathresult}\pgf‌​mathprintnumber{\pgfmathresult}} on pgfplots.sourceforge.net/gallery.html, which got used in my question and answer pgfplot log axis more than one tick label per decade (1,2,5,10) –  Ben Voigt Oct 24 at 21:41

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.