9

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}

1 Answers1

14

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}
Jake
  • 232,450