0

I'm trying to create a plot, where my x axis is scaled to base 2 and the ticks should be at the exact height of the coordinates. I have the logarithmic x axis, but i just can't get the ticks to be at the position of the coordinates. Also the ticks should be in the form of 2^14,2^15,... instead of 0.1*10^6 and so. Currently my plot is made by this code:

\begin{figure}[h]
\begin{tikzpicture}
    \begin{axis}[xlabel=n,ylabel=used time in ms,xmode=log]
        \addplot coordinates{ (2^14, 8) (2^15, 26) (2^16, 72) (2^17, 185) (2^18, 414) (2^19,956) (2^20,2017) };
        \addplot coordinates{ (2^14, 9) (2^15, 28) (2^16, 73) (2^17, 195) (2^18, 441) (2^19,1032) (2^20,2155) };
        \addplot coordinates{ (2^14, 8) (2^15, 23) (2^16, 65) (2^17, 175) (2^18, 406) (2^19,937) (2^20,2189) };
        \addplot coordinates{ (2^14, 10) (2^15, 30) (2^16, 83) (2^17, 229) (2^18, 536) (2^19,1216) (2^20,2669) };
        \addplot coordinates{ (2^14, 8) (2^15, 24) (2^16, 64) (2^17, 177) (2^18, 412) (2^19,960) (2^20,2045) };
        \end{axis}
\end{tikzpicture}
\end{figure} 

Currently, it looks like below picture. enter image description here But it should look like this, but with 2^14,2^15,.. instead of 14,15,... . I made this plot by just leaving out the base in my coordinates.

0

Welcome to TeX-SE! Are you looking for log basis x=2?

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[xlabel=$n$,ylabel=used time in ms,xmode=log,log basis x=2]
        \addplot coordinates{ (2^14, 8) (2^15, 26) (2^16, 72) (2^17, 185) (2^18, 414) (2^19,956) (2^20,2017) };
        \addplot coordinates{ (2^14, 9) (2^15, 28) (2^16, 73) (2^17, 195) (2^18, 441) (2^19,1032) (2^20,2155) };
        \addplot coordinates{ (2^14, 8) (2^15, 23) (2^16, 65) (2^17, 175) (2^18, 406) (2^19,937) (2^20,2189) };
        \addplot coordinates{ (2^14, 10) (2^15, 30) (2^16, 83) (2^17, 229) (2^18, 536) (2^19,1216) (2^20,2669) };
        \addplot coordinates{ (2^14, 8) (2^15, 24) (2^16, 64) (2^17, 177) (2^18, 412) (2^19,960) (2^20,2045) };
        \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.