5

With the MWE below, I get the x-axis multiplier along with the x-axis label as shown in the figure. enter image description here

However, the y-axis label is at the right position. How do I move the x-axis multiplier to an appropriate position that matches the present y-axis multiplier in PGFPlot?

MWE

% used PGFPlots v1.14
\documentclass{article}
\usepackage{filecontents}
\usepackage{pgfplots}

\begin{filecontents*}{pgfplots.dat}
Level   Cost    Error   Fourth
1,7,8.471e-02,3
2,31,3.044e-02,5
3,111,1.022e-02,7
4,351,3.303e-03,9
5,1023,1.038e-03,11
6,2815,3.196e-04,13
7,7423,9.657e-05,15
8,18943,2.873e-05,17
9,47103,8.437e-06,19
\end{filecontents*}

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
    \begin{axis}[
        xlabel = Cost,
        ylabel = Error,
        ]
        \addplot table[x index=1, y index=2, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 1}
        \addplot table[x index=1, y index=0, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 2}
        \addplot table[x index=1, y index=3, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 3}     
        \addplot table[x index=3, y index=1, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 4}
        \addplot table[x index = 0, y index=1, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 5}
        \addplot table[x index=3, y index=3, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 6}
        \addplot table[x index=3, y index=0, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 7}
        \addplot table[x index=2,y index=1, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 8}
        \addplot table[x index = 0, y index=3, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 9}
        \addplot table[x index = 0, y index=2, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 10}
        \addplot table[x index=2, y index=2, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 11}
        \addplot table[x index=2, y index=0, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 12}
    \end{axis}
\end{tikzpicture}
\caption{PGFPLOT graph}
\end{figure}
\end{document}
1

1 Answer 1

7

See : Placement of scale tick labels in pgfplots

Below I make attempts with the following :

    every x tick scale label/.style={at={(rel axis cs:1,0)},anchor=south west,inner sep=1pt},

(left) and (right)

    every x tick scale label/.style={at={(xticklabel cs:1)},anchor=south west},

The output

enter image description here

The code

\documentclass{standalone}
\usepackage{filecontents}
\usepackage{pgfplots}
\begin{filecontents*}{pgfplots.dat}
Level   Cost    Error   Fourth
1,7,8.471e-02,3
2,31,3.044e-02,5
3,111,1.022e-02,7
4,351,3.303e-03,9
5,1023,1.038e-03,11
6,2815,3.196e-04,13
7,7423,9.657e-05,15
8,18943,2.873e-05,17
9,47103,8.437e-06,19
\end{filecontents*}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        xlabel = Cost,
        ylabel = Error,
        every x tick scale label/.style={at={(rel axis cs:1,0)},anchor=south west,inner sep=1pt},
        ]
        \addplot table[x index=1, y index=2, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 1}
        \addplot table[x index=1, y index=0, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 2}
        \addplot table[x index=1, y index=3, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 3}     
        \addplot table[x index=3, y index=1, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 4}
        \addplot table[x index = 0, y index=1, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 5}
        \addplot table[x index=3, y index=3, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 6}
        \addplot table[x index=3, y index=0, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 7}
        \addplot table[x index=2,y index=1, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 8}
        \addplot table[x index = 0, y index=3, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 9}
        \addplot table[x index = 0, y index=2, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 10}
        \addplot table[x index=2, y index=2, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 11}
        \addplot table[x index=2, y index=0, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 12}
    \end{axis}
\end{tikzpicture}
\begin{tikzpicture}
    \begin{axis}[
        xlabel = Cost,
        ylabel = Error,
        every x tick scale label/.style={at={(xticklabel cs:1)},anchor=south west},
        ]
        \addplot table[x index=1, y index=2, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 1}
        \addplot table[x index=1, y index=0, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 2}
        \addplot table[x index=1, y index=3, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 3}     
        \addplot table[x index=3, y index=1, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 4}
        \addplot table[x index = 0, y index=1, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 5}
        \addplot table[x index=3, y index=3, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 6}
        \addplot table[x index=3, y index=0, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 7}
        \addplot table[x index=2,y index=1, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 8}
        \addplot table[x index = 0, y index=3, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 9}
        \addplot table[x index = 0, y index=2, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 10}
        \addplot table[x index=2, y index=2, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 11}
        \addplot table[x index=2, y index=0, col sep=comma] {pgfplots.dat};
        \addlegendentry{Case 12}
    \end{axis}
\end{tikzpicture}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .