# pgfplots: Use \times symbol for scientific notation in plot axes

When creating a plot like this one

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
scaled y ticks=false,
yticklabel style={
/pgf/number format/.cd,
sci,
sci generic={mantissa sep=\times,exponent={10^{#1}}}
}
]
(1, 972817.3879)
(2, 1436186.725)
};
\end{axis}
\end{tikzpicture}

\end{document}


I'm trying to use scientific notation in the y axis with \times as the mantissa separator instead of the default \cdot. The exponent is not showing up, though. I looked at Section 4.12.1 in the pgfplots manual and Section 2.7 in the pgfplotstable manual and followed the examples there, but there were no examples using this particular case with yticklabel.

How do I fix this?

The plot may be viewed here:

-

This seems to work:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\pgfkeys{/pgf/number format/.cd,
sci,
sci generic={mantissa sep=\times,exponent={10^{#1}}}}
\begin{axis}[
scaled y ticks=false,
xticklabel style={/pgf/number format/.cd,fixed},
]
(1, 972817.3879)
(2, 1436186.725)
};
\end{axis}
\end{tikzpicture}

\end{document}


-
I've found that I can also move the \pgfkeys command inside of the tikzpicture environment so that it is only in effect inside of that scope. –  Nick Moe Nov 8 '12 at 2:24
@NickMoe yes; it's better to move it keep the change local; I'll edit my answer to reflect this. –  Gonzalo Medina Nov 8 '12 at 2:27
One minor niggle I have with this solution is that 0 is displayed as 0 x 10^0 which most journals would frown upon. Is there a way to override the display and simply display it as 0? (Yes, it's silly to have a linear plot ranging from 0 to 10^6 but I'd be curious to know!) –  G. H. Hardly Jan 8 '13 at 22:28

# ####?

We need more #! Four to be exact: ####1.

## Code

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
scaled y ticks=false,
yticklabel style={
/pgf/number format/.cd,
sci,
sci generic={mantissa sep=\times,exponent=10^{####1}}
}
]
(1, 972817.3879)
(2, 1436186.725)
};
\end{axis}
\end{tikzpicture}
\end{document}


## Using directly \pgfmathprintnumber

You can use the style yticklabel and its internal \tick macro directly with \pgfmathprintnumber. The superscript is—as you already know—the first parameter, but as nesting goes we need the second level, therefore: ##1.

\documentclass{article}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
scaled y ticks=false,
yticklabel={
\pgfmathprintnumber[
sci,
sci generic={
mantissa sep=\times,
exponent={10^{##1}}
}
]{\tick}
}
]
(1, 972817.3879)
(2, 1436186.725)
};
\end{axis}
\end{tikzpicture}
\end{document}


## Output

-

You can see the explanation for the tick scale binop option in page 233 of the pgplots manual.

Try the following code:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
scaled y ticks=false,
yticklabel style={
/pgf/number format/.cd,
sci,
sci generic={mantissa sep=\times,exponent={10^{#1}}}
},
tick scale binop={\textbackslash times} % Change \cdot to \times as mantissa separator
]
(1, 972817.3879)
(2, 1436186.725)
};
\end{axis}
\end{tikzpicture}

\end{document}


## Edit

Gonzalo Medina already has posted a workaround regarding the missing exponents. Just in case it is an option not to write the mantissa the way you did, you can have the following option:

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

\begin{tikzpicture}
\begin{axis}[tick scale binop=\times,
]