My question on the placement of the scale tick label is related to Placement of scale tick labels in pgfplots. In contrast, I do not want to have the label placed behind the x-axis, but behind the last x-tick, as it is recommended for APS journals. Please see the examples given in https://journals.aps.org/authors/axis-labels-and-scales-on-graphs-h18.
-
Who comes up with this nonsense I will never understand – percusse Mar 16 '16 at 12:52
-
Don't you like the way I asked, or don't you like the placement strategy? – ReedWood Mar 16 '16 at 13:58
-
I meant the journal requirement – percusse Mar 16 '16 at 14:00
1 Answers
Here is one option. The ticklabels are a series of individual nodes, and this relies on the last tick being the last one that is actually defined. First set every x tick label/.append style={alias=XTick,inner xsep=0pt}. alias gives a name to node, so it can used to refer to the node. All the ticklabels on the x axis is given that alias, but the last one defined will the active one. The second part, inner xsep=0pt means that there will be no horizontal whitespace in the ticklabel nodes, which makes the position of the scale label easier.
The scale label is placed with every x tick scale label/.style={at=(XTick.base east),anchor=base west}. The anchor base east is at the baseline of the node, on the right side. The base anchors are used because the exponent makes the scale label a little taller than the ticklabel, so using just east/west would make the alignment wrong.
\documentclass[border=4mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
scaled x ticks=true,
every x tick label/.append style={alias=XTick,inner xsep=0pt},
every x tick scale label/.style={at=(XTick.base east),anchor=base west}
]
\addplot coordinates {(0,0)(100000,1)};
\end{axis}
\end{tikzpicture}
\end{document}
- 206,688
-
Thanks for the solution and your comprehensive explanation. As a small addition, the binary opperator which defaults to \cdot can be adjusted by
tick scale binop=\times,– ReedWood Mar 18 '16 at 14:28
