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.

I am using pgfplots to create simple theoretical graphs, so I use middle axis line style. What bothers me is that

  • x axis label is above instead of below or right of x axis and
  • y axis label is right instead of left or above of y axis.

I have extensively studied pgfplots manual (I find it much more complex and disordered than tikz manual) and tried things to regulate this myself using stuff like every axis x label/.style={at={(current axis.right)},anchor=north west}, but to no avail. How can I solve this problem?

\documentclass{scrartcl}
\usepackage{pgfplots}

\begin{document}

\pgfplotsset{standard/.style={axis x line=middle,axis y line=middle,enlarge x limits=0.15,enlarge y limits=0.15}}

\begin{tikzpicture}
\begin{axis}[standard,xlabel=$t$,ylabel=$v$,xtick={0,1.7},xticklabels={0,$t_1$},ytick={0,21},yticklabels={0,$v_0$}]
\addplot[thick,color=black] coordinates { (0,21) (1.7,21) (8.7,0) };
\end{axis} 
\end{tikzpicture}

\end{document}
share|improve this question
1  
@Jake I've rephrased. IMHO pgfplots is fine package, so it would "deserve" better structured and clearer manual. –  Pygmalion Aug 23 '12 at 11:16
    
I still don't really see the point of putting that sentence into the question. It adds no value to the question, and it's unlikely to lead to better documentation for PGFplots. I think the constructive thing to do would be to remove the sentence and instead write an email to the PGFplots author Christian Feuersaenger, explaining what you think could be done to improve the documentation. –  Jake Aug 23 '12 at 11:55
add comment

1 Answer 1

up vote 12 down vote accepted

You almost had it: The axis anchors you're looking for are called current axis.right of origin and current axis.above origin. The anchors are shown on the very simple and clear diagram on page 254 of the manual.

\documentclass{scrartcl}
\usepackage{pgfplots}

\begin{document}

\pgfplotsset{
    standard/.style={
        axis x line=middle,
        axis y line=middle,
        enlarge x limits=0.15,
        enlarge y limits=0.15,
        every axis x label/.style={at={(current axis.right of origin)},anchor=north west},
        every axis y label/.style={at={(current axis.above origin)},anchor=north east}
    }
}

\begin{tikzpicture}
\begin{axis}[
    standard,
    xlabel=$t$,
    ylabel=$v$,
    xtick={0,1.7},
    xticklabels={0,$t_1$},
    ytick={0,21},
    yticklabels={0,$v_0$}
]
\addplot[thick,color=black] coordinates { (0,21) (1.7,21) (8.7,0) };
\end{axis} 
\end{tikzpicture}

\end{document}
share|improve this answer
    
Indeed. Believe or not I spent at least 1/2 hour searching and listing manual and did not find that page. –  Pygmalion Aug 23 '12 at 11:17
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.