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 have the following latex code but unfortunately cannot get the ytick to be of my choice.

\documentclass{article}

\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}

\begin{center}
    \begin{tikzpicture}
        \begin{axis}[
            xlabel=Trail Run \#,
            ylabel=Task completion time,
            xtick={0, 4, 8, 12, 16, 20},
            ytick={0, 1, 2, 3, 4, 5, 6},
        legend style={
                at={(0.5,0.5)},
                anchor=center}]

        \addplot[smooth,color=black,mark=*]
            plot coordinates {
                (1, 5.372137)
                (2, 5.401571)
                (3, 5.418153)
                (4, 5.409281)
                (5, 5.440709)
                (6, 5.425516)
                (7, 5.366961)
                (8, 5.392147)
                (9, 5.345825)
                (10, 5.366253)
                (11, 5.320773)
                (12, 5.373887)
                (13, 5.338346)
                (14, 5.322246)
                (15, 5.399925)
                (16, 5.349757)
                (17, 5.345629)
                (18, 5.336819)
                (19, 5.364673)
                (20, 5.402730)  
            };
        \addlegendentry{XY at 3x3}

        \addplot[smooth,color=magenta,mark=*]
            plot coordinates {
                (1, 4.349543)
                (2, 4.348597)
                (3, 4.349540)
                (4, 4.348221)
                (5, 4.344659)
                (6, 4.350545)
                (7, 4.345121)
                (8, 4.337458)
                (9, 4.344044)
                (10, 4.349293)
                (11, 4.344615)
                (12, 4.349939)
                (13, 4.346299)
                (14, 4.341717)
                (15, 4.345412)
                (16, 4.351933)
                (17, 4.351421)
                (18, 4.338126)
                (19, 4.345590)
                (20, 4.348072)
            };
        \addlegendentry{YX at 3x3}
        \end{axis}
    \end{tikzpicture}
\end{center}

\end{document}

In this case I've specifically changed the legend's position which I didn't really want to. I want the legend to be on south east (which I can do) but I want the ytick to be more like — {0, 1, 2, 3, 4, 5, 6} so I've both the graphs near each other and make terminal '0' as the reference.

enter image description here

Any thoughts?

share|improve this question
    
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Benedikt Bauer Feb 21 '13 at 22:34
    
Hi; I've added the required lines of code. Also, added the 'ytick' line of code that I'm having issues with. Thanks. –  flippex17 Feb 21 '13 at 22:37
1  
Are you perhaps looking for ymax=6, ymin=0? –  Peter Grill Feb 21 '13 at 22:39
    
Wow! So trivial. Thank you very much. –  flippex17 Feb 21 '13 at 22:53
1  
We'd like to keep answers separate from questions, so you should write a separate answer instead of editing your answer into the question. Self-answers are perfectly admissible, and a well-written answer may earn you additional reputation. –  Benedikt Bauer Feb 21 '13 at 23:14

1 Answer 1

up vote 2 down vote accepted

Since you really want to control the min and max y values, then you need to set them ymax=6, ymin=0. Adding these options yields:

enter image description here

share|improve this answer
    
Thank you for the help. –  flippex17 Feb 23 '13 at 0:41

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.