[Tex/LaTex] pgfplots: Forcing Scientific Notation for y Axis

pgfplotstikz-pgf

I wish to force PGFPlots to use the same scientific notation exponent for all y tick labels, with the exponent placed above the graph, turning this style

enter image description here

into this style

enter image description here

I'm currently using scaled y ticks = true with no effect. I'm aware I could use scaled y ticks=base 10:2 to manually specify to use 1E2, but I'm looking for a more general solution.

Best Answer

I assume that you are looking for y tick label style={/pgf/number format/sci}. See also Chapter 4.13.1 (Frequently Used Number Printing Settings) in the current pgfplots manual ( I find it a bit difficult for beginners since this is tikz stuff as I understand it and not pgfplots -specific), see also* manual of pgfplotstable Chapter 2.7 (Number Formatting Options).

I do not know how to get the common mantissa sepearte from the ticks and at the top of the axis: Any experts here?

\documentclass{article}
\usepackage{pgfplots}
\begin{document}

% Based on http://pgfplots.sourceforge.net/gallery.html
\begin{tikzpicture}
    \begin{axis}[
        xlabel=$x$,
        ylabel={$f(x) = x^2 - x +4$},
        % Added
        y tick label style={/pgf/number format/sci},
    ]
    % use TeX as calculator:
    \addplot {x^2 - x +4};
    \end{axis}
\end{tikzpicture}

\end{document}

*"The options related to number printing as such are described in all detail in the manual for PgfplotsTable, which comes with pgfplots."

enter image description here