TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

simple question (I hope)

Using pgfplots 1.5.1, miktex 2.9 on Windows 7 32 bits. I'd like to hide the tick marks at the right and top side of the plot, but without losing the lines (e.g. keep the plot axis style as box but only keep tick marks in the left y axis and bottom x axis, keeping the lines in the upper x axis (without tick marks nor labels) and right y axis (without tick marks nor labels)

If i use ytick=\empty it removes all of the labels and ticks, but I don't want that, I just want the extra y and x ticks removed.

So far I've tried:

every extra y tick = \empty,
every extra y tick/.style={\empty},
extra y ticks={},
extra ytick =\empty, 
hide extra y ticks,
extra y tick style={tickwidth=0cm,major tick length=0cm},

But no luck,

Any help is much appreciated.

Best regards,

(edit: Forgot to add I'm using Latex->PDF profile)

share|improve this question
up vote 14 down vote accepted

The position of the tick marks is set using the key tick pos=<left|right|both> for the x and y axis simultaneously, and xtick pos and ytick pos to set the tick marks separately. In your case, you want to set ytick pos=left.

\begin{axis}[ytick pos=left]
\addplot {rnd};

The extra y tick options refer to something different: You can manually add additional tick positions, "extra ticks", to highlight certain positions. You specify where to add new tick positions using extra y ticks={<list>}, and set the styles for these extra ticks using extra y tick style=<options>. Here's an example, highlighting the y position 0.5, which ordinarily doesn't get a tick mark:

    ytick pos=left,
    extra y ticks={0.5},
    extra y tick style={red, yticklabel pos=right,ytick pos=right}]
\addplot {rnd};
share|improve this answer
Brilliant as always Jake, thank you very much. – Jose R Feb 5 '12 at 2:57
As an addition, now that Jake has pointed the answer, looking it up in the manual shows that this is on section 4.14.2 Tick Alignment: Positions and Shifts, first paragraph. – Jose R Feb 5 '12 at 6:27
@JoseR Thanks for the reference to the manual. But for questions that someone has already asked, this site is so much faster ... – Ethan Bolker Jun 5 '13 at 19:18
@Jake If you have a ylabel set, and the extra y ticks are wide, then the ylabel gets offset to the left—presumably because the calculations are taking into account the width of the labels as if they were on the left. Do you know how to fix this? – wchargin Nov 1 '14 at 2:46

Your Answer


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.