Quantcast
Channel: Automatically put PGFPlots xtick scale label in x axis label - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 3

Automatically put PGFPlots xtick scale label in x axis label

$
0
0

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}

Output from this code is:X-axis scale label should be in x axis label.


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>