# Pgfplots Scientific Notation 2^x

I am plotting a logarithmic graph and since the values are relatively large, pgfplots is outputting the values in the y-axis in terms of 10x . However, I'd like to output it the format 2x.

I read the documentation but it's not very clear in terms of how to achieve this. Any help would be greatly appreciated!

A code snippet for my graph is shown below:

\begin{figure}[!h]
\begin{tikzpicture}
\begin{axis}[xmin = 0, ymin = 0, scale only axis, height=5cm,
width=\textwidth, legend pos=north west, xlabel=$n$,ylabel=$k$, width=\textwidth]
\addplot[mark=none, color=blue] table [x = $n$, y = $K2$]{data/data.dat};
\addlegendentry{$F_2$}
\addplot[mark=none, color=red] table [x = $n$, y = $K3$]{data/data.dat};
\addlegendentry{$F_3$}
\addplot[mark=none, color=green] table [x = $n$, y = $K256$]{data/data.dat};
\addlegendentry{$F_{256}$}
\end{axis}
\end{tikzpicture}
\caption{Optimum $k$ to minimise complexity}
\label{graph:k}
\end{figure}

The output:

How would I get the y-axis to be in terms of 2^x, please? Thank you!

You can simply add ymode=log and then define the base number with log basis y={<number>} in the axis options.

\begin{axis}[ymode=log,log basis y={2},xmin = 0, ymin = 0, scale only axis, height=5cm,
width=\textwidth, legend pos=north west, xlabel=$n$,ylabel=$k$, width=\textwidth, ]

Output (example with other data):

Code:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{figure}[!h]
\begin{tikzpicture}
\begin{axis}[ymode=log,log basis y={2},xmin = 0, ymin = 0, scale only axis, height=5cm,
width=\textwidth, legend pos=north west, xlabel=$n$,ylabel=$k$, width=\textwidth, ]
(5,     8.312e-02)
(17,    2.547e-02)
(49,    7.407e-03)
(129,   2.102e-03)
(321,   5.874e-04)
(769,   1.623e-04)
(1793,  4.442e-05)
(4097,  1.207e-05)
(9217,  3.261e-06)
};
%\addplot[mark=none, color=blue] table [x = $n$, y = $K2$]{data/data.dat};
%\addlegendentry{$F_2$}
%\addplot[mark=none, color=red] table [x = $n$, y = $K3$]{data/data.dat};
%\addlegendentry{$F_3$}
%\addplot[mark=none, color=green] table [x = $n$, y = $K256$]{data/data.dat};
%\addlegendentry{$F_{256}$}
\end{axis}
\end{tikzpicture}
\caption{Optimum $k$ to minimise complexity}
\label{graph:k}
\end{figure}
\end{document}
• Perfect, thank you very much! – João Duarte Jun 28 at 21:16