8

How can I display tick marks on only one axis of a pgfplots graph?

Here is some simple code to work with:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
    \begin{axis}
        [
            xticklabels={,,},
            xlabel=${x}$,
            ylabel=${f_{h}\left(x\right)}$,
            width=190 pt
        ]
        \addplot+[mark=none, smooth, black] (\x, {2/(1+e^(-\x))-1});
    \end{axis}
\end{tikzpicture}
\end{document}

How can the tick marks on, say, the x axis be removed while retaining the tick marks on the y axis?

1 Answer 1

9

You can say xtick=\empty to remove the tick marks and tick labels on the x axis:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
    \begin{axis}
        [
            xtick=\empty,
            xlabel=${x}$,
            ylabel=${f_{h}\left(x\right)}$,
            width=190 pt
        ]
        \addplot+[mark=none, smooth, black] {2/(1+e^(-x))-1};
    \end{axis}
\end{tikzpicture}
\end{document}
1
  • This is what I need. Thanks muchly for your assistance!
    – d3pd
    Commented May 14, 2013 at 18:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .