23

How do you remove the tick marks on only one axis in pgfplots?

In my MWE, you'll notice slightly darker part to the y grid lines where the ticks are. I'd rather just have the grid lines, with no ticks, but also I'd like to keep the ticks on the x-axis. I had previously used tickwidth=0, but that gets rid of the x ticks, too.

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
    xtick pos=left,
    ymajorgrids=true,
]
\addplot {rnd};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

33

The drawing style of the y ticks can be changed with ytick style={<options>}, so you can for example do

ytick style={draw=none}

in \pgfplotsset or the axis options to hide them.

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{ytick style={draw=none}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
    xtick pos=left,
    ymajorgrids=true,
]
\addplot {rnd};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

| improve this answer | |
13

Use ytick=\empty in the axis options (worked in pgfplots 1.12.1):

Found the solution here.

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
    \begin{tikzpicture}
         \begin{axis}[
            ytick=\empty
            ] 
            \addplot {rnd};
        \end{axis}
    \end{tikzpicture}
\end{document}
| improve this answer | |
  • 1
    But this removes both the tick marks and the tick labels, which may or may not be desired. The answer by Torbjørn allows removal of the tick marks but keeping the labels. – Mårten W Mar 23 '19 at 10:34

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.