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?

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}
  • This is what I need. Thanks muchly for your assistance! – d3pd May 14 '13 at 18:49

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.