5

Is there a way to only move the y-tick labels to the right? The option yticklabel pos=right automatically moves the axis-label, too.

Here a MWE of how the axis-label is also moved:

\documentclass[xcolor=x11names]{article}
\usepackage{graphicx}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.9}
\usepackage{palatino}
\usepackage[euler-digits]{eulervm}
\begin{document}
    \begin{tikzpicture}
        \newcommand{\scaling}{0.5}
        \pgfplotsset{
            myaxis/.style={
                width={\scaling\textwidth},
                height={\scaling\textwidth/1.61803398875},
            },
        }
        \begin{semilogyaxis}[
            myaxis,
            xlabel={$x$},
            ylabel={$y$},
            ymin=1e-6,
            ymax=1e12,
            xmin=-4,
            xmax=4,
            scale only axis,
            ytick={1e-5,1e2,1e9},
            yticklabels={$10^{-5}$,$10^2$,$10^{9}$},
            yticklabel pos=right
        ]
        \addplot[very thick,color=blue!70!green!80,samples=500,domain=-4:4] {abs(1/(1+x))};
        \addplot[very thick,color=blue!30!green!80,samples=500,domain=-4:4] {abs(1/(1+x*x))};
        \end{semilogyaxis}
    \end{tikzpicture}
\end{document}
1
2

It is possible to adjust the label positioning manually.

\documentclass[xcolor=x11names]{article}
\usepackage{graphicx}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.9}
\usepackage{palatino}
\usepackage[euler-digits]{eulervm}
\begin{document}
    \centering
    \begin{tikzpicture} %
        \newcommand{\scaling}{0.5}
        \pgfplotsset{ %
            myaxis/.style={ %
                width={\scaling\textwidth}, %
                height={\scaling\textwidth/1.61803398875}, %
            }, 
        } %
        %  
        \pgfplotsset{every axis y label/.append style={yshift=7.75cm}}  %adjust the position with yshift           
        \begin{semilogyaxis}[ %
            myaxis, %
            xlabel={$x$}, %
            ylabel={$y$}, %
            ymin=1e-6, %
            ymax=1e12, %
            xmin=-4, %
            xmax=4, %
            scale only axis,
            ytick={1e-5,1e2,1e9},
            yticklabels={$10^{-5}$,$10^2$,$10^{9}$},
            yticklabel pos=right
        ] %
        \addplot[very thick,color=blue!70!green!80,samples=500,domain=-4:4] {abs(1/(1+x))};
        \addplot[very thick,color=blue!30!green!80,samples=500,domain=-4:4] {abs(1/(1+x*x))};
        \end{semilogyaxis} %
    \end{tikzpicture} %
\end{document}

enter image description here

1
  • Since both answers involve some manual tweaking I will take this one, as is does not require clip=false .
    – NOhs
    Jan 13 '15 at 8:15
1

An alternative is to disable the axis label via ylabel={} then add a node for y label on the left side. clip=false is required, though.

enter image description here

Code

\documentclass[xcolor=x11names]{article}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% General Setup

\usepackage{graphicx}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.9}

\usepackage{palatino}
\usepackage[euler-digits]{eulervm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Begin Document

\begin{document}

    \centering
    \begin{tikzpicture} %
        \newcommand{\scaling}{0.5}
        \pgfplotsset{ %
            myaxis/.style={ %
                width={\scaling\textwidth}, %
                height={\scaling\textwidth/1.61803398875}, %
            }, 
        } %
        %               
        \begin{semilogyaxis}[ %
            myaxis, %
            xlabel={$x$}, %
            ylabel={$y$}, %
            ymin=1e-6, %
            ymax=1e12, %
            xmin=-4, %
            xmax=4, %
            scale only axis,
            ytick={1e-5,1e2,1e9},
            yticklabels={$10^{-5}$,$10^2$,$10^{9}$},
            yticklabel pos=right,ylabel={},
            clip=false,
        ] %
        \addplot[very thick,color=blue!70!green!80,samples=500,domain=-4:4] {abs(1/(1+x))};
        \addplot[very thick,color=blue!30!green!80,samples=500,domain=-4:4] {abs(1/(1+x*x))};
         \node[rotate=90] () at (axis cs: -5,1000) {$y$};
        \end{semilogyaxis} %
    \end{tikzpicture} %
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.