[Tex/LaTex] PGFPlots: Logarithmic axes and scaling


I'm trying to plot some data where the X axis is logarithmic. The data runs from ~30 microseconds up to 10 milliseconds. It looks much cleaner to have the x-ticks looking like

{0.1 ms, 1 ms, 10 ms}


{10^-4 s, 10^-3 s, 10^-2 s}.

In other words, I would like my tick labels to be presented in fixed point (i.e., not as exponentials), and scaled (multiplied by 1000).

To achieve this effect, I've tried using

    [xmin=1e-6, xmax=1e-3, domain=1e-6:1e-3,
    scaled x ticks=real:1e-3,
    xtick scale label code/.code={},
    log ticks with fixed point]
    \addplot {x};

but logarithmic axes seem to ignore the "scaled x ticks" instructions. Any help would be much appreciated.


Best Answer

It appears as if you want to rescale the x coordinates without extracting some common factor. The scaled x ticks feature has the main use case of generating a common tick factor which is placed into some node... and, in fact, pgfplots has no builtin support for scaled ticks and log axes as it is typically no use-case.

However, rescaling the x coordinates is a use-case, and it is quite simple to implement by means of x filter:


    log ticks with fixed point,
    % for log axes, x filter operates on LOGS.
    % and log(x * 1000) = log(x) + log(1000):
    x filter/.code=\pgfmathparse{#1 + 6.90775527898214},
\addplot table {
0.0001 10
0.001 20
0.01 15

enter image description here

Related Question