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.

I have a graph with two logarithmic axes but I wish to set the labels of one of them to display in fixed point format. Is this possible? Below is a minimum example of how to get both axes using the fixed point format. I want the x axis to be fixed point.

\begin{figure}[H]
\centering
\begin{tikzpicture}
    \begin{loglogaxis}[
        xlabel=Processes,
        ylabel=Run time (Seconds)
        log ticks with fixed point
    ]
    \addplot[mark=*,blue] plot coordinates {
        (1,0.005584)
        (2,0.003083)
        (4,0.001586)
        (8,0.006259)
    };
    \addlegendentry{100000}

    \addplot[color=red,mark=x]
        plot coordinates {
            (1,0.036002)
            (2,0.024381)
            (4,0.014283)
            (8,0.008018)
        };
    \addlegendentry{1000000}

    \addplot[color=green,mark=o]
        plot coordinates {
            (1,0.334952)
            (2,0.178412)
            (4,0.092895)
            (8,0.053607)
        };
    \addlegendentry{10000000}
    \end{loglogaxis}
\end{tikzpicture}
\caption{Number of processes against run time}
\end{figure}
share|improve this question
add comment

1 Answer

up vote 10 down vote accepted

In this case, you shouldn't use the log ticks with fixed point style, but rather set the format for the x axis tick labels to something like xticklabel=\pgfmathparse{exp(\tick)}\pgfmathprintnumber{\pgfmathresult}, which will evaluate the exponential expression and print the fixed point number. Note, however, that that will lead to curious tick values:

For your data, you should set the logarithmic basis of the x axis to log basis x=2, and the tick labels to xticklabel=\pgfmathparse{2^\tick}\pgfmathprintnumber{\pgfmathresult}:

\documentclass[]{article}
\usepackage{filecontents,pgfplots}

\begin{document}
\begin{tikzpicture}
    \begin{loglogaxis}[
        xlabel=Processes,
        ylabel=Run time (Seconds),
        log basis x=2,
        xticklabel=\pgfmathparse{2^\tick}\pgfmathprintnumber{\pgfmathresult}
    ]
    \addplot[mark=*,blue] plot coordinates {
        (1,0.005584)
        (2,0.003083)
        (4,0.001586)
        (8,0.006259)
    };
    \addlegendentry{100000}

    \addplot[color=red,mark=x]
        plot coordinates {
            (1,0.036002)
            (2,0.024381)
            (4,0.014283)
            (8,0.008018)
        };
    \addlegendentry{1000000}

    \addplot[color=green,mark=o]
        plot coordinates {
            (1,0.334952)
            (2,0.178412)
            (4,0.092895)
            (8,0.053607)
        };
    \addlegendentry{10000000}
    \end{loglogaxis}
\end{tikzpicture}

\end{document}
share|improve this answer
    
Thanks Jake. Just what I'm after. –  Jonathan Evans Feb 16 '12 at 15:00
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.