I'm trying to put xtick scale label
(defined by pgfkey /pgfplots/xtick scale label code/.code
) in x axis label, between variable name and unit.
I've tried executing using the option xlabel = {$ x $ (\pgfkeysvalueof{/pgfplots/xtick scale label code/.code} m)}
to put in but this doesn't work.
I've also tried the following xtick scale label code/.code={\pgfkeyssetvalue{/pgfplots/xlabel}{#1}}
to force PGFPlots to change my xlabel but it doesn't work as well.
I know I can do this by hand, but I'm interested in automatic approach. Is there a workaround or a solution to this?
My MWE is:
\documentclass{article}\usepackage{pgfplots}\pgfplotsset{compat=1.14}\begin{document} \begin{tikzpicture} \begin{axis}[ scaled x ticks=true, scaled y ticks = false, y tick label style={/pgf/number format/fixed}, %xtick scale label code/.code={\pgfkeyssetvalue{/pgfplots/xlabel}{#1}}, xlabel = {$ x $ (\pgfkeysvalueof{/pgfplots/xtick scale label code/.code} m)}, ylabel = {$ y $}, ] \addplot[line width=3pt] coordinates {(0.0,0.0)(100,1)(400,2)(10000,0)}; \end{axis} \end{tikzpicture}\end{document}