Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How can I use absolutely placed y labels, but still adjust the absolute placement? In the below example, I want to be able to get the two plots to align exactly, including the y labels.

If I add

ylabel absolute,

to the list of arguments of

\begin{axis[

I cannot use

ylabel shift = 0.1cm,

in the same argument list. If I skip ylabel absolute, I can use ylabel shift, but then I have to use different values for yshift (and it is not obvious exactly which values) to get equal spacing. Ideally, I would like to first fix the position of the y label (as ylabel absolute does) and then shift it (as ylabel shift does). How can that be done?

MWE:

\documentclass{article}
\usepackage[tightpage,active]{preview}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5}

\begin{document}
\begin{preview}
\begin{tikzpicture}
    \begin{axis}[
        height=6cm,
        width=9cm,
        xlabel=$x$,
        ylabel=$y$]
    \addplot[smooth,color=blue]
      plot coordinates {
        (0,3)
        (2,4)
        (3,1)
    };
    \addlegendentry{One curve}

    \addplot[smooth,color=red]
        plot coordinates {
            (0,0)
            (1,2)
            (2,1)
            (3,0)
        };
    \addlegendentry{Another curve}
    \end{axis}
\end{tikzpicture}

\begin{tikzpicture}
    \begin{axis}[
        height=6cm,
        width=9cm,
        xlabel=$x$,
        ylabel=$y$]
    \addplot[smooth,color=blue]
      plot coordinates {
        (0,3)
        (2,4)
        (3,1)
    };
    \addlegendentry{One curve}

    \addplot[smooth,color=red]
        plot coordinates {
            (0,-10)
            (1,2)
            (2,1)
            (3,1)
        };
    \addlegendentry{Another curve}
    \end{axis}
\end{tikzpicture}
\end{preview}
\end{document}

enter image description here

share|improve this question
    
You can use ylabel absolute, ylabel style={yshift=1cm} to shift the labels. Is that what you mean? –  Jake Mar 7 '13 at 16:45
    
Yes, that was what I wanted to do. Is ylabel shift=1cm an old command, and ylabel style={yshift=1cm} the one to replace it? –  hjb981 Mar 7 '13 at 17:18
    
ylabel shift can result in a different direction for the shift compared to yshift. Clearly, yshift simply shifts upward or downward, but ylabel shift shifts along "the outer normal vector". Try it for a 3D axis to see the difference. –  Christian Feuersänger Mar 8 '13 at 19:14
    
@Jake Please write your comment here up as an answer –  Joseph Wright Aug 10 '13 at 6:46
    
Christian Feuersänger, thank you for your comment, I saw it just now. @Jake If you make your comment an answer, I will make it an accepted answer. –  hjb981 Aug 14 '13 at 17:54
add comment

1 Answer

You can use ylabel absolute, ylabel style={yshift=1cm} to shift the labels.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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